API Usage
Choose the model protocol first
The new homepage and model gateway support several compatible protocols. Check the model name and capabilities in the model catalog, then use the matching endpoint.
| Protocol | Base URL | Request path | Authentication |
|---|---|---|---|
| OpenAI Chat Completions | https://www.fastapi.cool/v1 | /chat/completions | Authorization: Bearer |
| OpenAI Responses | https://www.fastapi.cool/v1 | /responses | Authorization: Bearer |
| Claude Messages | https://www.fastapi.cool | /v1/messages | x-api-key |
| Gemini | https://www.fastapi.cool | /v1beta/models/{model}:generateContent | x-goog-api-key |
WARNING
Not every model supports all four protocols. A correct model name used with an incompatible endpoint may return a 404 or protocol-conversion error.
The updated protocol conversion layer improves interoperability among OpenAI Chat, Responses, Claude, and Gemini, and adds Responses support for DeepSeek and GLM channels. Ollama channels can pass Claude Messages to upstream /v1/messages and pass OpenAI Responses and Responses Compact through unchanged; vLLM-compatible requests preserve thinking_token_budget. Chat/Responses conversion preserves explicit frequency_penalty and presence_penalty values (including 0) plus prompt_cache_key; an upstream may still reject unsupported fields, and Codex channels remove penalties that their backend does not accept. Claude conversion omits tools when no tool was supplied; when a tool exists without a parameter definition, it preserves the tool and supplies a valid empty-object input schema instead of silently dropping it. Availability still depends on the selected model and backend channel configuration; do not infer protocol support from the provider name alone.
OpenAI SDK
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://www.fastapi.cool/v1",
)
response = client.chat.completions.create(
model="MODEL_ID",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://www.fastapi.cool/v1",
});
const response = await client.chat.completions.create({
model: "MODEL_ID",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);Responses API
curl https://www.fastapi.cool/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"input": "Introduce yourself in one sentence."
}'Claude Messages
curl https://www.fastapi.cool/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"max_tokens": 256,
"messages": [
{"role": "user", "content": "Hello"}
]
}'Gemini
curl "https://www.fastapi.cool/v1beta/models/MODEL_ID:generateContent" \
-H "x-goog-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{"parts": [{"text": "Hello"}]}
]
}'Common endpoints
| Purpose | Path |
|---|---|
| OpenAI Chat Completions | /v1/chat/completions |
| OpenAI Responses | /v1/responses |
| Model list | /v1/models |
| Claude Messages | /v1/messages |
| Embeddings | /v1/embeddings |
| Image generation | /v1/images/generations |
| OpenAI Video create | /v1/videos |
| OpenAI Video retrieve | /v1/videos/{task_id} |
| Generic plugin task create | /v1/tasks/{plugin_key} |
| Generic plugin task retrieve | /v1/tasks/{task_id} |
| Task artifact list | /v1/tasks/{task_id}/artifacts |
| Text to speech | /v1/audio/speech |
| Speech to text | /v1/audio/transcriptions |
| Gemini | /v1beta/models/{model}:generateContent |
Supported endpoints and parameters vary by model. Refer to the model catalog and the official API specification for that model. Test a model in Playground, then review the request in Usage Logs.
GET /v1/models returns a protocol-shaped list based on authentication: a Bearer token receives the OpenAI-style data response, while an x-goog-api-key header or ?key= query parameter receives the Gemini-style models response.
A task plugin can claim provider-native routes, OpenAI Responses (stream, synchronous, or background modes), and OpenAI Video. A request is handled only when the currently enabled plugin explicitly claims the protocol and is bound to the selected model. The generic /v1/tasks/{plugin_key} create endpoint returns a public task ID, which can then be used with the task and artifact endpoints. Request validation failures return HTTP 400 and should not be retried as server faults.
Streaming
For models that support OpenAI-compatible streaming, add:
{
"stream": true
}After the request, Usage Logs show its stream status. If the client disconnects early, the upstream stream does not finish normally, or the request fails, the stream status and error details help identify where it stopped.
Authentication
OpenAI-compatible endpoints use a Bearer token:
Authorization: Bearer YOUR_API_KEYThe native Claude and Gemini compatible endpoints use x-api-key and x-goog-api-key, respectively, as shown above.