Using Cloudflare With Teklrn AI
Teklrn AI supports both Cloudflare Workers AI and Cloudflare AI Gateway. Workers AI runs Cloudflare-hosted models directly, while AI Gateway routes requests through your Cloudflare gateway to one or more upstream providers.
Website: https://developers.cloudflare.com/ai/
Provider Options
| Provider ID | Use it for | Required values |
|---|---|---|
cloudflare-workers-ai | Cloudflare-hosted Workers AI models | Account ID and API key |
cloudflare-ai-gateway | Routing through Cloudflare AI Gateway | Account ID, Gateway ID, and Gateway API token |
You can enter these values interactively with /connect in the TUI or teklrn auth from the CLI, or provide them through environment variables.
Cloudflare Workers AI
Get Credentials
- Open the Cloudflare dashboard and select your account.
- Copy the Account ID from the dashboard.
- Create an API token that can invoke Workers AI.
Configure Teklrn
Open Settings (gear icon) and go to the Providers tab to add Cloudflare Workers AI. If your account ID is not already available from the environment, Teklrn prompts for it while connecting the provider.
Cloudflare AI Gateway
Get Credentials
- Create or open a Cloudflare AI Gateway.
- Copy your Account ID and Gateway ID.
- Create a Gateway API token.
Configure Teklrn
Open Settings (gear icon) and go to the Providers tab to add Cloudflare AI Gateway. Teklrn prompts for the account ID and gateway ID when they are not already set in the environment.
Advanced Configuration
If your organization provides a fully configured gateway URL, set provider.<id>.options.baseURL. When baseURL is configured, Teklrn skips the built-in Account ID and Gateway ID checks because the URL already identifies the target service.
{
"provider": {
"cloudflare-ai-gateway": {
"options": {
"baseURL": "https://gateway.example.com/v1"
}
}
}
}
The gateway credential from CLOUDFLARE_API_TOKEN or CF_AIG_TOKEN is sent when the request goes to the Cloudflare gateway host gateway.ai.cloudflare.com. For a gateway reached on another host, such as a Cloudflare custom domain, pass the credential in the provider headers:
{
"provider": {
"cloudflare-ai-gateway": {
"options": {
"baseURL": "https://ai.example.com/compat",
"headers": { "cf-aig-authorization": "Bearer <gateway-token>" }
}
}
}
}
Troubleshooting
CLOUDFLARE_ACCOUNT_ID is missing— setCLOUDFLARE_ACCOUNT_IDor reconnect the provider with/connectso Teklrn can store the account ID in auth metadata.CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_GATEWAY_ID missing— set both values or runteklrn auth cloudflare-ai-gateway.CLOUDFLARE_API_TOKEN (or CF_AIG_TOKEN) is required— set one of those variables or reconnect Cloudflare AI Gateway withteklrn auth cloudflare-ai-gateway.- Model errors through AI Gateway — confirm the gateway route supports the selected upstream provider/model and that your Gateway API token has access.