OpenAI-compatible by design
Surf exposes a focused subset of the OpenAI API. Existing server-side clients can connect by changing baseURL and using a Surf API key. Requests enter one endpoint while routing stays internal to the network.
https://route.futurixai.com/v1Make your first request
- 01
Create a key
Sign in, open API keys, and copy the new key when it is shown. Store it in a server-side secret manager.
- 02
Export it locally
TERMINALexport SURF_API_KEY="surf_your_key" - 03
Send a chat completion
JAVASCRIPTimport OpenAI from "openai"; const surf = new OpenAI({ apiKey: process.env.SURF_API_KEY, baseURL: "https://route.futurixai.com/v1", }); const response = await surf.chat.completions.create({ model: "kimi-k2.6", messages: [{ role: "user", content: "Explain distributed inference." }], }); console.log(response.choices[0].message.content);
Bearer keys, kept server-side
Send your key in the Authorization header. Keys are revealed once and stored as hashes. Never expose them in browser code, mobile bundles, or public repositories.
Authorization: Bearer $SURF_API_KEYCreate a completion
/chat/completionscurl https://route.futurixai.com/v1/chat/completions \
-H "Authorization: Bearer $SURF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k2.6",
"messages": [{"role":"user","content":"Hello from Surf"}],
"max_completion_tokens": 4096
}'A public model alias from the catalog.
Conversation messages using system, user, assistant, and tool roles.
Return server-sent events as tokens become available.
Defaults to 4,096 and is capped at 32,768.
Function definitions and tool-selection behavior.
Request JSON mode or a structured JSON schema.
Read output as it arrives
Set stream: true to receive OpenAI-compatible server-sent events. Keep the connection open until the terminal event. Usage is settled after the stream completes or disconnects.
const stream = await surf.chat.completions.create({
model: "glm-5.2",
messages: [{ role: "user", content: "Return a short status update." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Let models request your functions
Define tools with JSON Schema. Surf returns tool calls through the standard assistant message shape; your application executes them and sends the result back as a tool message.
{
"model": "kimi-k2.7-code",
"messages": [{"role":"user","content":"Check the build status."}],
"tools": [{
"type": "function",
"function": {
"name": "get_build_status",
"description": "Return the current build state",
"parameters": {
"type": "object",
"properties": {"build_id":{"type":"string"}},
"required": ["build_id"]
}
}
}]
}Constrain the response shape
Models marked with structured-output support accept response_format. Validate returned JSON in your application even when a schema is supplied.
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "deployment_check",
"strict": true,
"schema": {
"type": "object",
"properties": {"ready":{"type":"boolean"}},
"required": ["ready"],
"additionalProperties": false
}
}
}Discover available aliases
Use the catalog for human-readable capabilities or query the authenticated model endpoint at runtime.
/modelscurl https://route.futurixai.com/v1/models \
-H "Authorization: Bearer $SURF_API_KEY"Errors use the OpenAI object shape
Inspect the HTTP status and error code. Successful inference responses include x-request-id; log it with your own trace so a request can be located without exposing provider routing identifiers.
{
"error": {
"message": "The model 'unknown' does not exist.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}Metered against actual tokens
Surf reserves enough credit for the request, then settles against terminal usage. The default output cap is 4,096 tokens and the platform maximum is 32,768. Model context limits are listed in the model catalog; pricing is published per million tokens.
View pricing