Search docs

Search docs, endpoints, errors

Chat Completions API

OpenAI-compatible chat completions with built-in reasoning, tool use, and streaming.

POST/v1/chat/completions
https://api.apodex.ai

Overview

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.

Base URL
https://api.apodex.ai
Auth
Bearer API key
Format
OpenAI-compatible
This page is the contract for the deep research tiers. The core models 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.

ModelsWhen to useContext windowMax completionPricing
Deep Research
apodex-1-1-deep-research
When the answer exists and needs to be found fast.128k64k $5.00 / $20.00
Deep Solve
apodex-1-1-deep-solve
When the answer requires inference, judgment, or tradeoff analysis.128k64k $5.00 / $25.00
Deep DiscoverPreview
apodex-1-1-deep-discover
When the problem is hard, high-stakes, novel, or easy to get wrong.128k256k $10.00 / $100.00

Input / Output / 1M tokens

Apodex 1.0 models and GET /v1/models
ModelsWhen to useContext windowMax completionPricing
Deep Research
apodex-1-0-deep-research
When the answer exists and needs to be found fast.256k16k $10.00 / $40.00
Deep Solve
apodex-1-0-deep-solve
When the answer requires inference, judgment, or tradeoff analysis.256k16k $10.00 / $50.00
Deep DiscoverPreview
apodex-1-0-deep-discover
When the problem is hard, high-stakes, novel, or easy to get wrong.128k256k $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.

Example
curl https://api.apodex.ai/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"
Response
{
  "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

HeaderValueDescription
Authorization
Required
Bearer YOUR_API_KEYYour Apodex API key
Content-Type
Required
application/jsonMust be application/json

Body parameters

model
stringRequired

Model ID to use, e.g. "apodex-1-1-deep-research"

messages
arrayRequired

Array of message objects with "role" (system/user/assistant) and "content" fields

stream
booleandefault 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_tokens
integer

Maximum number of tokens to generate in the completion

mcp_servers
array

Array 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:

Phase 1: Reasoning

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.

Phase 2: Final Answer

After reasoning completes, the final answer streams via delta.content, token by token, just like standard OpenAI streaming.

SSE Stream Example
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.

Response
{
  "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_reasonDescription
stopThe model completed normally
errorThe workflow failed due to an internal error. An error object is included in the chunk.
cancelledThe request was cancelled (client disconnect or explicit cancel)
usage fieldDescription
prompt_tokensTokens in the input prompt
completion_tokensTokens generated in the completion
total_tokensSum of prompt + completion tokens
completion_tokens_details.reasoning_tokensHidden 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_queriesNumber 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:

TypeDescription
thinkingInternal reasoning and analysis
web_searchSearching the web for information
fetch_url_contentFetching and reading content from a URL
execute_pythonExecuting Python code in a sandboxed environment
execute_commandRunning a shell command
tool_callCalling an MCP tool or external function

Capabilities & Limits

CapabilityStatus
Context window256k 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 callingOpenAI-style tools / tool_choice are not supported. Use mcp_servers for external tools.
Structured outputresponse_format / json_schema are not supported.
Prompt cachingcache_control is not supported.
Multimodal inputImage 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.

StatusCodeDescription
400bad_requestInvalid request body or missing required fields
401unauthorizedMissing or invalid API key
402insufficient_balanceAccount balance is too low to process the request
429rate_limitedToo many requests. Retry after the Retry-After header value.
503service_unavailableThe service is temporarily overloaded or down for maintenance
Error Response Format
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid API key provided.",
    "type": "authentication_error"
  }
}
Docs | Apodex API Platform