We use cookies. Cookies and browser storage keep you signed in and remember your preferences. With your permission we also measure how the site is used. You can any time. See our cookie policy.

Chat completions

Endpoints

Chat completions

Send chat messages to any text model with POST /chat/completions, using the OpenAI chat format, roles, parameters and response fields.

Try it in the playground

The chat completions endpoint uses the OpenAI chat format and works with every text model in the catalog: GPT, Claude, Gemini, Llama, DeepSeek, Mistral and hundreds more. The request body goes to the upstream provider unchanged. api14 only checks your key, model, limits and balance, then records usage when the request finishes.

POST https://api14.com/api/v1/chat/completions
Authorization: Bearer sk-api14-...
Content-Type: application/json

Request

ParameterTypeDescription
modelstring, requiredModel id, e.g. anthropic/claude-sonnet-4.5. Variants like :online or :nitro are allowed. See Model ids.
messagesarray, requiredConversation as { role, content } objects. Roles: system, developer, user, assistant, tool.
modelsstring[]Fallback models to try in order if the first one fails. See Provider routing.
streambooleanStream tokens as server-sent events. See Streaming.
max_tokens / max_completion_tokensintegerUpper bound on generated tokens.
temperaturenumberSampling temperature, usually 0–2.
top_p, top_k, min_p, top_anumberOther sampling controls. Models that don't support them ignore them.
frequency_penalty, presence_penalty, repetition_penaltynumberRepetition controls.
stopstring | string[]Stop sequences.
seedintegerBest-effort deterministic sampling.
logprobs, top_logprobsboolean, integerReturn token log probabilities when the model supports them.
tools, tool_choice, parallel_tool_callsFunction calling. See Tool calling.
response_formatobjectJSON mode or JSON Schema output. See Structured outputs.
reasoning, include_reasoningobject, booleanThinking controls. See Reasoning.
plugins, web_search_optionsWeb search. See Web search.
providerobjectUpstream provider preferences. See Provider routing.
modalitiesstring[]e.g. ["image", "text"] for image output, or ["text", "audio"] for audio output.
predictionobjectPredicted output ({ type: "content", content }) to cut latency on edits.
transformsstring[]e.g. ["middle-out"] to compress prompts that exceed the context window.
userstringYour own end-user identifier.

Message content can be a string or an array of content parts (text, image_url, file, input_audio). See Vision & files.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api14.com/api/v1",
  apiKey: process.env.API14_API_KEY,
});

const result = await client.chat.completions.create({
  "model": "openai/gpt-5-mini",
  "messages": [
    {
      "role": "user",
      "content": "Explain vector databases in two sentences."
    }
  ]
});
console.log(result.choices[0].message.content);

Response

{
  "id": "gen-1760000000-abc123",
  "object": "chat.completion",
  "created": 1760000000,
  "model": "anthropic/claude-sonnet-4.5",
  "provider": "Anthropic",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": { "role": "assistant", "content": "Hello! How can I help you today?" }
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "completion_tokens_details": { "reasoning_tokens": 0 },
    "cost": 0.000171
  }
}

usage.cost is the cost of the request in USD. api14 debits it from your balance after the request finishes. The id is the generation id, which you can look up later with Generation lookup.

Billing notes

  • You pay the model's listed price; the charge is returned in usage.cost. See Pricing & billing.
  • You are not charged for failed requests (any 4xx or 5xx status).
  • If the request includes models: [...], every fallback model must be allowed for your key and plan, or the gateway rejects the request before it is sent upstream.

Errors

StatusCodeWhen
400model_requiredmodel is missing.
400invalid_jsonThe body is not a JSON object.
401invalid_api_keyThe key is missing, invalid or revoked.
402insufficient_balanceYour USD balance is $0.
403model_not_allowed / plan_requiredYour key's allowlist or your plan does not cover this model.
404model_not_foundUnknown or disabled model id.
413payload_too_largeThe request body is larger than 25 MB.
429rate_limited / daily_limit_reachedRPM limit or the key's daily USD limit was reached.
502upstream_unavailableThe upstream provider could not be reached.

Upstream errors such as context length exceeded or content moderation come back with their original status code and the same error shape. See Errors.