Chat Completions API
OpenAI-compatible chat completions with built-in reasoning, tool use, and streaming.
/v1/chat/completionshttps://api.apodex.aiOverview
The Chat Completions API is the primary interface for interacting with Apodex models. It follows the OpenAI Chat Completions format, so you can use the OpenAI SDK or any compatible client. The API is served by the frontier gateway.
apodex-1.1 and apodex-1.1-mini share this same /v1/chat/completions path, but their semantics differ deliberately — stream default, failure surface, sampling parameters and billing unit all change. For the core models, see OpenAI-compatible API.Models
Pass the model id below in the model parameter when creating a chat completion.
| Models | When to use | Context window | Max completion | Pricing |
|---|---|---|---|---|
Deep Research apodex-1-1-deep-research | When the answer exists and needs to be found fast. | 128k | 64k | $5.00 / $20.00 |
Deep Solve apodex-1-1-deep-solve | When the answer requires inference, judgment, or tradeoff analysis. | 128k | 64k | $5.00 / $25.00 |
Deep DiscoverPreview apodex-1-1-deep-discover | When the problem is hard, high-stakes, novel, or easy to get wrong. | 128k | 256k | $10.00 / $100.00 |
Input / Output / 1M tokens
Apodex 1.0 models and GET /v1/models
| Models | When to use | Context window | Max completion | Pricing |
|---|---|---|---|---|
Deep Research apodex-1-0-deep-research | When the answer exists and needs to be found fast. | 256k | 16k | $10.00 / $40.00 |
Deep Solve apodex-1-0-deep-solve | When the answer requires inference, judgment, or tradeoff analysis. | 256k | 16k | $10.00 / $50.00 |
Deep DiscoverPreview apodex-1-0-deep-discover | When the problem is hard, high-stakes, novel, or easy to get wrong. | 128k | 256k | $10.00 / $100.00 |
List via API
The same data is available programmatically — useful for clients that want to enumerate or check model capabilities at runtime.
curl https://api.apodex.ai/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"{
"object": "list",
"data": [
{
"id": "apodex-1-1-deep-research",
"object": "model",
"created": 1700000000,
"owned_by": "apodex",
"context_length": 131072,
"max_completion_tokens": 65536
},
{
"id": "apodex-1-1-deep-solve",
"object": "model",
"created": 1700000000,
"owned_by": "apodex",
"context_length": 131072,
"max_completion_tokens": 65536
},
{
"id": "apodex-1-1-deep-discover",
"object": "model",
"created": 1700000000,
"owned_by": "apodex",
"context_length": 131072,
"max_completion_tokens": 262144
}
]
}Create Chat Completion
Send a conversation to the model and receive a completion. Supports streaming (SSE) and non-streaming modes.
Headers
| Header | Value | Description |
|---|---|---|
AuthorizationRequired | Bearer YOUR_API_KEY | Your Apodex API key |
Content-TypeRequired | application/json | Must be application/json |
Body parameters
| Parameter | Description |
|---|---|
modelstringRequired | Model ID to use, e.g. "apodex-1-1-deep-research" |
messagesarrayRequired | Array of message objects with "role" (system/user/assistant) and "content" fields |
streambooleandefault true | Whether to stream the response via SSE. Defaults to true — note this differs from OpenAI's default of false. Always pass stream explicitly when using OpenAI SDKs. |
max_tokensinteger | Maximum number of tokens to generate in the completion |
mcp_serversarray | Array of MCP server configs ({name, url, headers?, access_token?, oauth?}) for external tool access |
modelModel ID to use, e.g. "apodex-1-1-deep-research"
messagesArray of message objects with "role" (system/user/assistant) and "content" fields
streamWhether to stream the response via SSE. Defaults to true — note this differs from OpenAI's default of false. Always pass stream explicitly when using OpenAI SDKs.
max_tokensMaximum number of tokens to generate in the completion
mcp_serversArray of MCP server configs ({name, url, headers?, access_token?, oauth?}) for external tool access
Request
curl -X POST https://api.apodex.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "apodex-1-1-deep-research",
"messages": [
{
"role": "user",
"content": "What are the latest trends in AI?"
}
],
"stream": true
}'Streaming Response
When stream: true (the default), the response is delivered as Server-Sent Events (SSE). Each line is prefixed with data: followed by a JSON chunk. The stream ends with data: [DONE]. The stream has two phases:
The model emits reasoning steps via delta.reasoning_steps. Each step has a type (e.g. thinking, web_search) and a content field with the step details.
After reasoning completes, the final answer streams via delta.content, token by token, just like standard OpenAI streaming.
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_steps":[{"type":"thinking","thought":"Let me analyze this question..."}]}}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"reasoning_steps":[{"type":"web_search","web_search":{"search_keywords":["latest AI trends 2026"]}}]}}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Here are"}}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" the latest"}}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":256,"total_tokens":268,"completion_tokens_details":{"reasoning_tokens":45},"num_search_queries":1}}
data: [DONE]Non-Streaming Response
Set stream: false to receive the full response as a single JSON object. The response waits until the model finishes generating before returning.
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1712345678,
"model": "apodex-1-1-deep-research",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here are the latest trends in AI...",
"reasoning_steps": [
{
"type": "thinking",
"thought": "Let me analyze this question..."
},
{
"type": "web_search",
"web_search": {
"search_keywords": ["latest AI trends 2026"],
"search_results": [{"title": "...", "url": "...", "snippet": "..."}]
}
}
]
},
"finish_reason": "stop"
}
],
"search_results": [{"title": "...", "url": "...", "snippet": "..."}],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 256,
"total_tokens": 268,
"completion_tokens_details": {
"reasoning_tokens": 45
},
"num_search_queries": 1
}
}Finish Reason & Usage
The final chunk (streaming) or the response (non-streaming) includes a finish_reason and a usage object.
| finish_reason | Description |
|---|---|
stop | The model completed normally |
error | The workflow failed due to an internal error. An error object is included in the chunk. |
cancelled | The request was cancelled (client disconnect or explicit cancel) |
| usage field | Description |
|---|---|
prompt_tokens | Tokens in the input prompt |
completion_tokens | Tokens generated in the completion |
total_tokens | Sum of prompt + completion tokens |
completion_tokens_details.reasoning_tokens | Hidden reasoning tokens used by the model to produce the answer. Counted as part of completion_tokens and billed as output. OpenAI-compatible nested shape. |
num_search_queries | Number of billed fetch_url_content invocations during reasoning. Omitted when zero. |
Reasoning Step Types
During the reasoning phase, the model can emit the following step types:
| Type | Description |
|---|---|
thinking | Internal reasoning and analysis |
web_search | Searching the web for information |
fetch_url_content | Fetching and reading content from a URL |
execute_python | Executing Python code in a sandboxed environment |
execute_command | Running a shell command |
tool_call | Calling an MCP tool or external function |
Capabilities & Limits
| Capability | Status |
|---|---|
| Context window | 256k tokens per request, shared between input and output. |
| External tool use (MCP) | Supported via the mcp_servers request parameter; currently in private beta. Contact us for access. |
| Custom function calling | OpenAI-style tools / tool_choice are not supported. Use mcp_servers for external tools. |
| Structured output | response_format / json_schema are not supported. |
| Prompt caching | cache_control is not supported. |
| Multimodal input | Image and document inputs are supported on the platform but not yet exposed via the public API. Coming soon. |
OpenAI SDK Compatibility
Point any OpenAI SDK at the Apodex base URL and use your Apodex API key. The API is fully compatible with the OpenAI Chat Completions format, with one behavioral difference: stream defaults to true. Always pass stream explicitly — use stream=False for a plain JSON response; omitting it will make the SDK's non-streaming call receive SSE and fail to parse.
from openai import OpenAI
client = OpenAI(
base_url="https://api.apodex.ai/v1",
api_key="YOUR_API_KEY",
)
stream = client.chat.completions.create(
model="apodex-1-1-deep-research",
messages=[
{"role": "user", "content": "What are the latest trends in AI?"}
],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta
if delta.content:
print(delta.content, end="", flush=True)Error Responses
The API returns standard HTTP error codes with a JSON error body.
| Status | Code | Description |
|---|---|---|
400 | bad_request | Invalid request body or missing required fields |
401 | unauthorized | Missing or invalid API key |
402 | insufficient_balance | Account balance is too low to process the request |
429 | rate_limited | Too many requests. Retry after the Retry-After header value. |
503 | service_unavailable | The service is temporarily overloaded or down for maintenance |
{
"error": {
"code": "unauthorized",
"message": "Invalid API key provided.",
"type": "authentication_error"
}
}