ChatCompletions Format

ChatCompletions Format

Create a model response from conversation history. Supports streaming and non-streaming. Compatible with OpenAI Chat Completions API.

FieldValue
Base URLhttps://token.easyapi.com/v1
AuthenticationAuthorization: Bearer `API_KEY`
Example modelgpt-4
FormatOpenAI Chat Completions compatible
BillingPay as you go
Note: Full path: POST /v1/chat/completions. OpenAI SDK base_url must include /v1.Supports usage.include (cost in the response), models (fallback sequence) and provider.sort (routing preference); see the request body below.

Example model

Examples below use gpt-4 (GPT-4). Replace model and adjust size, quality, etc. per console docs when switching models.

Create chat completion

POSThttps://token.easyapi.com/v1/chat/completions

Create a model response from conversation history. Compatible with OpenAI Chat Completions API; supports streaming and non-streaming.

Request parameters

NameInTypeRequiredDescription
AuthorizationheaderstringYesEasyAPI API Key. Format: Bearer `API_KEY`
Content-TypeheaderstringYesRequest body format

Request body

NameTypeRequiredDescription
modelstringYesModel ID
messagesarray<object>YesConversation message list
temperaturenumberNoSampling temperature, default 1, range 0–2
top_pnumberNoNucleus sampling, default 1, range 0–1
nintegerNoNumber of completions, default 1, must be ≥ 1
streambooleanNoStream responses, default false
stream_optionsobjectNoExtra options for streaming
stopstring | array<string>NoStop sequence(s), string or string array
max_tokensintegerNoMax tokens to generate
max_completion_tokensintegerNoMax completion tokens
presence_penaltynumberNoPresence penalty, default 0, range -2–2
frequency_penaltynumberNoFrequency penalty, default 0, range -2–2
logit_biasobjectNoBias specific token probabilities
userstringNoEnd-user identifier for abuse monitoring
toolsarray<object>NoTool definitions the model may call
tool_choicestring | objectNoTool choice strategy, string or object
response_formatobjectNoResponse format, e.g. JSON Schema
seedintegerNoSeed for best-effort reproducibility
reasoning_effortstringNomedium
modalitiesarray<string>NoOutput modalities, e.g. text, audio
audioobjectNoAudio output configuration
usageobjectNoSet usage.include = true to add a cost field (USD for this request) to the usage object; for streaming it arrives in the final chunk that carries usage. The final charge is reported by GET /v1/generation
modelsarray<string>NoFallback model sequence (up to 5). When the primary model has no available channel, or the upstream fails before any output is sent, the next model is tried in order; limited to models this key may use
providerobjectNoRouting preference within the same priority tier: provider.sort = price picks the cheapest channel; latency picks the lowest measured time-to-first-token (end-to-end latency for non-streaming); throughput picks the highest measured output tokens/s. latency and throughput use live measurements of this model on each channel and fall back to channel health-check timing when no measurements exist. The model suffix :floor equals sort=price and :nitro equals sort=throughput

Example

{
  "model": "gpt-4",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "temperature": 0.7,
  "stream": false,
  "usage": {
    "include": true
  }
}

Response example

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1718452800,
  "model": "gpt-4",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 12,
    "total_tokens": 32,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "text_tokens": 20,
      "audio_tokens": 0,
      "image_tokens": 0
    },
    "completion_tokens_details": {
      "text_tokens": 12,
      "audio_tokens": 0,
      "reasoning_tokens": 0
    },
    "cost": 0.000124
  },
  "system_fingerprint": "fp_abc123"
}