Chat Completions
Reference
POST /v1/chat/completions
OpenAI-compatible Chat Completions API (with field-level annotations and streaming SSE details)
POST
Chat Completions
Overview
Quick Start
Send a request withmodel and messages. Use stream=true to receive SSE chunks.
Supported models:surf-ask,surf-research,surf-1.5,surf-1.5-instant,surf-1.5-thinking.
surf-askandsurf-researchare legacy models.surf-1.5,surf-1.5-instant, andsurf-1.5-thinkingare the new models. Legacy models remain available and the request format is unchanged.
Note: When usingsurf-researchandsurf-1.5, it is recommended to set the timeout to 10 minutes.
What’s new in surf-1.5
surf-1.5 is the recommended, next-generation model. Compared to legacy models, it’s designed for more advanced workflows:
- Enhanced performance: Delivers superior response quality with significantly reduced latency in
surf-1.5-instant, providing faster and more accurate results compared to legacy models. - Custom tool calls (function calling): Better support for defining tools via
toolsand orchestrating multi-step tool-augmented tasks. - Configurable reasoning depth: Use
reasoning_effort(low/medium/high) to trade off speed vs. deeper analysis. - Built for agent-style workflows: Works well with Surf extensions like
ability(capability constraints) andcitation(citation formats) in the same request shape.
Model variants: surf-1.5, surf-1.5-instant, surf-1.5-thinking
The surf-1.5 family includes three model variants with different reasoning capabilities:
-
surf-1.5-instant: A lightweight model optimized for fast responses to simple queries. -
surf-1.5-thinking: A more powerful model with deeper reasoning capabilities, designed to handle complex problems that require thorough analysis and multi-step reasoning. -
surf-1.5: An adaptive model that automatically selects betweensurf-1.5-instantandsurf-1.5-thinkingbased on the request parameters and problem complexity. This provides an optimal balance between speed and depth without requiring manual model selection.
Summary (What you can do)
- OpenAI-compatible: Use the OpenAI Chat Completions shape (
model,messages, optionalstream) and standardAuthorization: Bearer <API_KEY>. - Streaming (SSE): Set
stream=trueto receive incremental chunks (text/event-stream) and terminate ondata: [DONE]. - Custom tool calls: Provide
tools(OpenAI function calling). The model may request tool executions during generation. - Reasoning depth: Control analysis strength with
reasoning_effort:low/medium/high. - Surf extensions: Use
abilityto constrain available capability domains andcitationto request output citation formats. - Errors: This endpoint may return
400,401, or502(both streaming and non-streaming).
Examples
Non-streaming response example (with field annotations)
Request fields (model.CompletionsRequest)
Note: This endpoint follows the overall structure of OpenAIchat.completions, and additionally provides Surf extension fields such asabilityandcitation.
Single message in messages[] (model.Message)
Tool definitions in tools[] (model.Tool / model.ToolFunction)
Fields of the
function object:
Response fields (non-streaming JSON: model.CompletionsProxyResponse)
choices[] (model.CompletionsChoice)
message (model.CompletionsMessage)
usage (model.CompletionsUsage)
Streaming response (SSE: text/event-stream)
When stream=true, the server continuously streams SSE events. Each event block typically looks like:
Note: The current OpenAPI spec does not define a dedicated schema for streaming chunks. In the examples, each chunk’sobjectis typicallychat.completion.chunk, and incremental output is delivered viachoices[].delta(e.g.,role/content).finish_reasonis usuallynulluntil the stream ends.
Error response (model.BaseResponse)
This endpoint may return: 400, 401, 502 (both streaming and non-streaming).
Authorizations
Body
application/json
Request body (OpenAI-compatible)
Available options:
search, evm_onchain, solana_onchain, market_analysis, calculate Example:
Available options:
source, chart Example:
Available options:
surf-ask, surf-research, surf-1.5, surf-1.5-thinking, surf-1.5-instant Example:
"surf-ask"
Available options:
low, medium, high Example:
"medium"
Example:
false
Response
OK