v1

latestOpenAPI 3.1.0MIT2026-07-262861121.0 KB

Creates a completion for the provided prompt. This endpoint is available on a best-effort basis for legacy compatibility, and performance may be less consistent than /v1/chat/completions because not all upstream providers support the legacy completions API.

post/v1/completions

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.

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.).

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.

promptstring required

The text prompt to complete

max_tokensinteger

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

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

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

streamboolean

Whether to stream the response

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

Provider-agnostic repetition modifier (distinct from OpenAI penalties). Values >1 discourage repetition

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.

Example request

{
  "model": "minimax/minimax-m2.7"
}

Response

Text completion response

idstring

Unique identifier for the completion

objectstring

Object type, always 'text_completion'

createdinteger

Unix timestamp of when the completion was created

modelstring

Model used for completion