This commit is contained in:
Matt Silverlock 2025-12-23 15:42:19 +08:00 committed by GitHub
commit 05fd8a6ca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 67 additions and 0 deletions

View file

@ -338,6 +338,25 @@ export namespace Provider {
},
}
},
"cloudflare-ai-gateway": async () => {
const accountId = Env.get("CLOUDFLARE_ACCOUNT_ID")
const gateway = Env.get("CLOUDFLARE_GATEWAY_ID")
const apiKey = Env.get("CLOUDFLARE_API_TOKEN")
if (!accountId || !gateway) return { autoload: false }
return {
autoload: true,
options: {
baseURL: `https://gateway.ai.cloudflare.com/v1/${accountId}/${gateway}/compat`,
apiKey,
headers: {
"HTTP-Referer": "https://opencode.ai/",
"X-Title": "opencode",
}
}
}
},
cerebras: async () => {
return {
autoload: false,

View file

@ -323,6 +323,54 @@ If you encounter "I'm sorry, but I cannot assist with that request" errors, try
---
### Cloudflare AI Gateway
Cloudflare AI Gateway lets you proxy requests to AI providers through Cloudflare's infrastructure with caching, rate limiting, and analytics.
1. Head over to the [Cloudflare dashboard](https://dash.cloudflare.com/), navigate to **AI** > **AI Gateway**, and create a new gateway.
2. Set your Account ID and Gateway ID as environment variables:
```bash
export CLOUDFLARE_ACCOUNT_ID=your-32-character-account-id && export CLOUDFLARE_GATEWAY_ID=your-gateway-id
```
Or add them to your bash profile:
```bash title="~/.bash_profile"
export CLOUDFLARE_ACCOUNT_ID=your-32-character-account-id
export CLOUDFLARE_GATEWAY_ID=your-gateway-id
```
3. If your gateway has authentication enabled, also set your API token:
```bash title="~/.bash_profile"
export CLOUDFLARE_API_TOKEN=your-api-token
```
4. Many Cloudflare AI Gateway models are preloaded by default, run the `/models` command to select the one you want.
```txt
/models
```
You can also add additional models through your opencode config.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"cloudflare-ai-gateway": {
"models": {
"some-other-model": {}
}
}
}
}
```
---
### Cortecs
1. Head over to the [Cortecs console](https://cortecs.ai/), create an account, and generate an API key.