Baseten
Baseten ↗ provides infrastructure for building and deploying machine learning models at scale. Baseten offers access to various language models through a unified chat completions API.
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/basetenWhen making requests to Baseten, ensure you have the following:
- Your AI Gateway Account ID.
- Your AI Gateway gateway name.
- An active Baseten API token.
- The name of the Baseten model you want to use.
Baseten provides an OpenAI-compatible chat completions API for supported models.
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/baseten/v1/chat/completions \ --header 'Authorization: Bearer {baseten_api_token}' \ --header 'Content-Type: application/json' \ --data '{ "model": "openai/gpt-oss-120b", "messages": [ { "role": "user", "content": "What is Cloudflare?" } ] }'import OpenAI from "openai";
const apiKey = "{baseten_api_token}";const accountId = "{account_id}";const gatewayId = "{gateway_id}";const baseURL = `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/baseten`;
const openai = new OpenAI({ apiKey, baseURL,});
const model = "openai/gpt-oss-120b";const messages = [{ role: "user", content: "What is Cloudflare?" }];
const chatCompletion = await openai.chat.completions.create({ model, messages,});
console.log(chatCompletion);You can also use the OpenAI-compatible endpoint (/ai-gateway/usage/chat-completion/) to access Baseten models using the OpenAI API schema. To do so, send your requests to:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/compat/chat/completionsSpecify:
{"model": "baseten/{model}"}For models that don't use the OpenAI-compatible API, you can access them through their specific model endpoints.
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/baseten/model/{model_id} \ --header 'Authorization: Bearer {baseten_api_token}' \ --header 'Content-Type: application/json' \ --data '{ "prompt": "What is Cloudflare?", "max_tokens": 100 }'const accountId = "{account_id}";const gatewayId = "{gateway_id}";const basetenApiToken = "{baseten_api_token}";const modelId = "{model_id}";const baseURL = `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/baseten`;
const response = await fetch(`${baseURL}/model/${modelId}`, { method: "POST", headers: { "Authorization": `Bearer ${basetenApiToken}`, "Content-Type": "application/json", }, body: JSON.stringify({ prompt: "What is Cloudflare?", max_tokens: 100, }),});
const result = await response.json();console.log(result);Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark