API/chat/completions
The REST API for conversation, reasoning, tool calling and streaming. Codex, OpenCode, Kimi CLI and Grok CLI all use this endpoint.
https://api.framewharf.com/v1/chat/completionsAuthorization: Bearer sk-your_api_keyRequires model and messages. Take the model id from GET /v1/models.
curl "https://api.framewharf.com/v1/chat/completions" \
-H "Authorization: Bearer sk-your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"messages": [{"role": "user", "content": "Summarize the benefits of a unified API."}]
}'Set stream: true to receive each chunk over Server-Sent Events. The stream ends with data: [DONE].
curl --no-buffer "https://api.framewharf.com/v1/chat/completions" \
-H "Authorization: Bearer sk-your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"stream": true,
"messages": [{"role": "user", "content": "Suggest five product names for an AI app."}]
}'Declare tools in tools. The model replies with tool_calls, you run the function, then send the result back as a message with role: "tool".
{
"model": "qwen4-max",
"messages": [{"role": "user", "content": "What is the weather in Hanoi today?"}],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
}
]
}