Chat & messages
Call chat completions, responses, and Anthropic messages through one gateway.
OneHop speaks the protocols your SDK already uses. Point the base URL at the right family, pass a OneHop model slug, and your existing client works unchanged.
| Family | Base URL | Endpoints |
|---|---|---|
| OpenAI-compatible | https://api.onehop.ai/v1 | chat/completions, responses |
| Anthropic-compatible | https://api.onehop.ai/anthropic | v1/messages |
| Google GenAI / Vertex | https://api.onehop.ai/vertex-ai | models/{model}:generateContent |
The request and response bodies are passed through to the upstream provider.
OneHop only reads model, stream, and a little usage metadata — it does not
rewrite your payload, so tool calls, system prompts, and message shapes behave
exactly as the provider documents them.
Chat completions (OpenAI)
curl https://api.onehop.ai/v1/chat/completions \
-H "Authorization: Bearer $ONEHOP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.5",
"messages": [{ "role": "user", "content": "Explain prepaid billing in one line." }]
}'import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ONEHOP_API_KEY,
baseURL: "https://api.onehop.ai/v1",
});
const completion = await client.chat.completions.create({
model: "openai/gpt-5.5",
messages: [{ role: "user", content: "Hello from OneHop" }],
});Streaming
Set stream: true and read server-sent events as usual. OneHop streams chunks
straight through without buffering the whole response, and bills the real usage
once the upstream finishes.
curl https://api.onehop.ai/v1/chat/completions \
-H "Authorization: Bearer $ONEHOP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.5",
"stream": true,
"messages": [{ "role": "user", "content": "Stream a haiku" }]
}'Disconnects abort upstream
If your client disconnects mid-stream, OneHop aborts the upstream request. You are billed for usage the provider actually reported; otherwise the record is reconciled or marked failed.
Anthropic messages
The recommended Anthropic entry point is /anthropic/v1/messages. Use the
x-api-key header, just like the native Anthropic SDK.
curl https://api.onehop.ai/anthropic/v1/messages \
-H "x-api-key: $ONEHOP_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-opus-4.8",
"max_tokens": 256,
"messages": [{ "role": "user", "content": "Hello from OneHop" }]
}'Responses & Vertex
- Responses:
POST /v1/responses(or the short aliasPOST /responses) for clients built on the OpenAI Responses protocol. - Vertex / Gemini: point at
https://api.onehop.ai/vertex-aiand call:generateContent/:streamGenerateContentwith the model in the path.
To see which protocols a given model supports, filter the catalog —
/v1/models?protocol=anthropic_messages. See Models & discovery
for the full filter list.