POST /v1/chat/completions

Changed on

Creates a chat completion for the provided messages. The NanoGPT Advisor extension is available for non-streaming, platform-billed pay-as-you-go API-key requests that do not use client tools, structured output, inline moderation, BYOK, accountless payment, memory, or server-side content enhancements.

Request

  • Base URL
    https://nano-gpt.com/api
  • URL
    https://nano-gpt.com/api/v1/chat/completions
  • Auth
    • HTTP bearer
    • or none

Headers

X-Providerstring

Optional explicit provider override for supported open-source models (case-insensitive). Explicit provider selection is billed pay-as-you-go at the selected provider's price, including provider-selection markup; for subscription users it bypasses subscription coverage for that request.

X-Billing-Modestring

Optional billing override to force pay-as-you-go without an explicit provider, or to apply saved provider preferences to subscription-included traffic (e.g., paygo). Header name is case-insensitive.

x-x402'true'

Set to true on unauthenticated accountless x402 quote requests. Without this header, unauthenticated requests return 401 missing_api_key.

Request body

modelstring required

The model to use for completion. The model value may include supported model suffixes, including web search (':online', ':online/<provider>'), memory (':memory', ':memory-<days>'), reasoning visibility (':reasoning-exclude'), thinking variants where listed by the model catalog (':thinking'), and provider routing preferences for eligible models (':fast', ':cheap', ':caching', etc.). Model ID or compatibility alias. Append :reasoning-effort/<effort>, where effort is none, low, medium, high, xhigh, or max, to supply a default reasoning_effort. The suffix is stripped before model routing and is not listed as a separate model. Explicit reasoning generation settings take precedence, including enabled thinking when the suffix is none. The none suffix requests disabled reasoning where supported; it does not bypass model/provider restrictions. Other effort levels remain model/provider-specific.

billing_modestring

Billing override to force pay-as-you-go without an explicit provider, or to apply saved provider preferences to subscription-included traffic. Accepted values (case-insensitive): paygo, pay-as-you-go, pay_as_you_go, paid, payg.

billingModestring

Alias for billing_mode.

cachingboolean

When true, route to an available provider that is marked as prompt/input-caching capable for the requested provider-selection model. If no usable cache-capable provider exists, the request fails instead of falling back to a non-cache-capable provider. This is provider capability routing only; it does not add cache_control markers, configure cache TTLs, or force a cache write. The model suffixes ':caching', ':cache', and ':cached' request the same behavior.

stickyproviderboolean

Top-level routing control for caching: true. When caching is true, defaults to true and prefers the previously recorded provider for later matching requests from the same API key or session when still usable. Set false to require a cache-capable provider without sticky routing.

stickyProviderboolean

CamelCase alias for top-level stickyprovider. Distinct from prompt_caching.stickyProvider, which controls explicit prompt-cache failover behavior.

streamboolean

Whether to stream the response

service_tier'auto' | 'default' | 'flex' | 'fast' | 'priority'

Optional processing tier. Use flex for lower-cost variable-capacity processing or fast for higher-priority processing where supported. priority remains accepted as a legacy alias for Fast on OpenAI models. Discover model support with GET /api/v1/models?detailed=true and inspect supported_service_tiers; the basic model list intentionally omits this field.

temperaturenumber

Classic randomness control. Accepts any decimal between 0-2. If omitted, NanoGPT does not force a value and the routed provider/model default applies

max_tokensinteger

Upper bound on generated tokens. If omitted, NanoGPT does not enforce an explicit default and the routed provider/model default applies

top_pnumber

Nucleus sampling. When set below 1.0, trims candidate tokens to the smallest set whose cumulative probability exceeds top_p. Works well as an alternative to tweaking temperature

frequency_penaltynumber

Penalizes tokens proportionally to how often they appeared previously. Negative values encourage repetition; positive values discourage it

presence_penaltynumber

Penalizes tokens based on whether they appeared at all. Good for keeping the model on topic without outright banning words

repetition_penaltynumber

Penalizes tokens that already appear in the conversation, on most providers including the prompt. 1 turns it off and values above 1 discourage repetition. Values below 1 encourage repetition and can cause misspelled words and endless loops, especially with long prompts. Unlike frequency_penalty and presence_penalty, the neutral value is 1, not 0

top_kinteger

Caps sampling to the top-k highest probability tokens per step

top_anumber

Combines top-p and temperature behavior; leave unset unless a model description explicitly calls for it

min_pnumber

Ensures each candidate token probability exceeds a floor (0-1). Helpful for stopping models from collapsing into low-entropy loops

tfsnumber

Tail free sampling. Values between 0-1 let you shave the long tail of the distribution; 1.0 disables the feature

eta_cutoffnumber

Cut probabilities as soon as they fall below the specified tail threshold

epsilon_cutoffnumber

Cut probabilities as soon as they fall below the specified tail threshold

typical_pnumber

Typical sampling (aka entropy-based nucleus). Works like top_p but preserves tokens whose surprise matches the expected entropy

mirostat_mode0 | 1 | 2

Enables Mirostat sampling for models that support it. Set to 1 or 2 to activate

mirostat_taunumber

Mirostat target entropy parameter. Used when mirostat_mode is enabled

mirostat_etanumber

Mirostat learning rate parameter. Used when mirostat_mode is enabled

min_tokensinteger

For providers that support it, enforces a minimum completion length before stop conditions fire

stop_token_idsinteger[]

Numeric array that lets callers stop generation on specific token IDs. Not supported by many providers

include_stop_str_in_outputboolean

When true, keeps the stop sequence in the final text. Not supported by many providers

ignore_eosboolean

Allows completions to continue even if the model predicts EOS internally. Useful for long creative writing runs

no_repeat_ngram_sizeinteger

Extension that forbids repeating n-grams of the given size. Not supported by many providers

custom_token_bansinteger[]

List of token IDs to fully block

logit_biasobject

Object mapping token IDs to additive logits. Works just like OpenAI's version

prompt_logprobsboolean

Requests logprobs on the prompt itself when the upstream API allows it

seedinteger

Optional integer forwarded on model/provider routes that support seeded sampling. This may improve reproducibility but does not guarantee identical output. Results can change if NanoGPT selects a different automatic or fallback route, or if the provider changes its backend.

max_tool_callsinteger

Maximum number of built-in tool calls, such as native web searches, page opens and searches within a page, the model can make in one response. Applies to requests NanoGPT sends to OpenAI's Responses API, including GPT-5+ and o-series native search and your own OpenAI key (BYOK); calls past the cap are not run or billed. Other routes, and rerouted requests such as Auto Model, ignore it.

reasoning_effort'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'

Controls reasoning depth and acts as an explicit reasoning-mode signal. Any value other than "none" requests reasoning/thinking behavior. Use "none" to explicitly disable reasoning.

reasoning_delta_field'reasoning_content'

Shorthand for reasoning.delta_field

reasoning_content_compatboolean

Shorthand to force legacy reasoning_content fields in the response

Example request

{
  "model": "minimax/minimax-m2.7",
  "prompt_caching": {
    "ttl": "5m"
  }
}

Response

Chat completion response

idstring

Unique identifier for the completion

objectstring

Object type, always 'chat.completion'

createdinteger

Unix timestamp of when the completion was created

service_tierstring

Service tier used (echoed when provided on the request)

Changes

    • breaking

      added subschema #1 to the / request property allOf list

    • breaking

      the request property's min was increased to 0.00

    • info

      added the new optional request property

    • info

      added the new optional request property //

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      the request property // became optional

    • info

      the request property default value 1 was added

    • info

      added the new developer enum value to the request property //

    • info

      added the new fast enum value to the request property

    • info

      request property // list-of-types was widened by adding types null to media type application/json