Skip to content

Commit 4d3b307

Browse files
authored
[AI Gateway] Adding OpenRouter as a new model provider (#18442)
* Adding OpenRouter as a new model provider. * Adding H3s to examples. * Hiding redundant Overview page. * Adding "cURL" as H3s where applicable.
1 parent a9b9ed0 commit 4d3b307

File tree

15 files changed

+115
-5
lines changed

15 files changed

+115
-5
lines changed

src/content/docs/ai-gateway/providers/anthropic.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/anthropic`
1313

1414
## Examples
1515

16+
### cURL
17+
1618
```bash title="Example fetch request"
1719
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/anthropic/v1/messages \
1820
--header 'x-api-key: {anthropic_api_key}' \
@@ -27,6 +29,8 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/anthropic/v1
2729
}'
2830
```
2931

32+
### Use Anthropic SDK with JavaScript
33+
3034
If you are using the `@anthropic-ai/sdk`, you can set your endpoint like this:
3135

3236
```js title="JavaScript"

src/content/docs/ai-gateway/providers/azureopenai.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Your new base URL will use the data above in this structure: `https://gateway.ai
2727

2828
## Examples
2929

30+
### cURL
31+
3032
```bash title="Example fetch request"
3133
curl 'https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/azure-openai/{resource_name}/{deployment_name}/chat/completions?api-version=2023-05-15' \
3234
--header 'Content-Type: application/json' \
@@ -41,6 +43,8 @@ curl 'https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/azure-opena
4143
}'
4244
```
4345

46+
### Use `openai-node` with JavaScript
47+
4448
If you are using the `openai-node` library, you can set your endpoint like this:
4549

4650
```js title="JavaScript"

src/content/docs/ai-gateway/providers/bedrock.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ When making requests to Amazon Bedrock, replace `https://bedrock-runtime.us-east
2020

2121
With Bedrock, you will need to sign the URL before you make requests to AI Gateway. You can try using the [`aws4fetch`](https://github.com/mhart/aws4fetch) SDK.
2222

23-
## Example:
23+
## Examples
24+
25+
### Use `aws4fetch1` SDK with TypeScript
2426

2527
```typescript
2628
import { AwsClient } from "aws4fetch";

src/content/docs/ai-gateway/providers/cohere.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ When making requests to [Cohere](https://cohere.com/), replace `https://api.cohe
1717

1818
## Examples
1919

20+
### cURL
21+
2022
```bash title="Request"
2123
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/cohere/v1/chat \
2224
--header 'Authorization: Token {cohere_api_token}' \
@@ -31,6 +33,8 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/cohere/v1/ch
3133
}'
3234
```
3335

36+
### Use Cohere SDK with Python
37+
3438
If using the [`cohere-python-sdk`](https://github.com/cohere-ai/cohere-python), set your endpoint like this:
3539

3640
```js title="Python"

src/content/docs/ai-gateway/providers/google-ai-studio.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/google-ai
5151
}'
5252
```
5353

54-
### JavaScript
54+
### Use `@google/generative-ai` with JavaScript
5555

5656
If you are using the `@google/generative-ai` package, you can set your endpoint like this:
5757

src/content/docs/ai-gateway/providers/grok.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/grok/v1/chat
3737
}'
3838
```
3939

40+
### Use OpenAI SDK with JavaScript
41+
4042
If you are using the OpenAI SDK with JavaScript, you can set your endpoint like this:
4143

4244
```js title="JavaScript"
@@ -66,6 +68,8 @@ const completion = await openai.chat.completions.create({
6668
console.log(completion.choices[0].message);
6769
```
6870

71+
### Use OpenAI SDK with Python
72+
6973
If you are using the OpenAI SDK with Python, you can set your endpoint like this:
7074

7175
```python title="Python"
@@ -89,6 +93,8 @@ completion = client.chat.completions.create(
8993
print(completion.choices[0].message)
9094
```
9195

96+
### Use Anthropic SDK with JavaScript
97+
9298
If you are using the Anthropic SDK with JavaScript, you can set your endpoint like this:
9399

94100
```js title="JavaScript"
@@ -116,6 +122,8 @@ const msg = await anthropic.messages.create({
116122
console.log(msg);
117123
```
118124

125+
### Use Anthropic SDK with Python
126+
119127
If you are using the Anthropic SDK with Python, you can set your endpoint like this:
120128

121129
```python title="Python"

src/content/docs/ai-gateway/providers/groq.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ When making requests to [Groq](https://groq.com/), replace `https://api.groq.com
1717

1818
## Examples
1919

20+
### cURL
21+
2022
```bash title="Example fetch request"
2123
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/groq/chat/completions \
2224
--header 'Authorization: Bearer {groq_api_key}' \
@@ -32,6 +34,8 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/groq/chat/co
3234
}'
3335
```
3436

37+
### Use Groq SDK with JavaScript
38+
3539
If using the [`groq-sdk`](https://www.npmjs.com/package/groq-sdk), set your endpoint like this:
3640

3741
```js title="JavaScript"

src/content/docs/ai-gateway/providers/huggingface.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ When making requests to HuggingFace Inference API, replace `https://api-inferenc
1717

1818
## Examples
1919

20+
### cURL
21+
2022
```bash title="Request"
2123
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface/bigcode/starcoder \
2224
--header 'Authorization: Bearer {hf_api_token}' \
@@ -26,6 +28,8 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/huggingface/
2628
}'
2729
```
2830

31+
### Use HuggingFace.js library with JavaScript
32+
2933
If you are using the HuggingFace.js library, you can set your inference endpoint like this:
3034

3135
```js title="JavaScript"

src/content/docs/ai-gateway/providers/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
pcx_content_type: navigation
33
title: Model providers
44
sidebar:
5+
group:
6+
hideIndex: true
57
order: 3
68
---
79

src/content/docs/ai-gateway/providers/mistral.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/mist
5050
}'
5151
```
5252

53-
### JavaScript
53+
### Use `@mistralai/mistralai` package with JavaScript
5454

5555
If you are using the `@mistralai/mistralai` package, you can set your endpoint like this:
5656

0 commit comments

Comments
 (0)