Skip to main content
POST
cURL
POST /api/v1/completions is available on a best-effort basis for legacy OpenAI compatibility. Performance and behavior may be less consistent than POST /api/v1/chat/completions because not all upstream providers support the legacy completions API.
POST /api/v1/completions supports the same model suffix parser for provider routing (:fast, :cheap, etc.) and :reasoning-exclude, but this endpoint remains best-effort legacy compatibility. Prefer Chat Completions for new integrations. See Model Suffixes.
The body provider field accepts either the existing provider ID string or a structured routing object with fields such as order, only, ignore, sort, max_price, allow_fallbacks, and require_parameters. See Provider Selection > Provider Routing Object.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

X-Provider
string

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-Mode
string

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.

Body

application/json

Parameters for text completion

model
string
default:minimax/minimax-m2.7
required

The model to use for completion. The model value may include supported model suffixes, including web search (':online', ':online/'), memory (':memory', ':memory-'), reasoning visibility (':reasoning-exclude'), thinking variants where listed by the model catalog (':thinking'), and provider routing preferences for eligible models (':fast', ':cheap', ':caching', etc.).

Examples:

"minimax/minimax-m2.7"

"zai-org/glm-5:fast"

"zai-org/glm-5:cheap"

"openai/gpt-5.6-sol:online/exa-instant"

"openai/gpt-5.6-sol:online/exa-deep-reasoning"

prompt
string
required

The text prompt to complete

billing_mode
string

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.

billingMode
string

Alias for billing_mode.

provider

Optional provider override or structured provider routing controls for provider-selection-capable models. A string explicitly selects one provider. An object can set soft order, hard pins, exclusions, sort preference, price caps, fallback behavior, and parameter-capability requirements.

max_tokens
integer

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

Required range: x >= 1
temperature
number

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

Required range: 0 <= x <= 2
top_p
number
default:1

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

Required range: 0 <= x <= 1
stream
boolean
default:false

Whether to stream the response

stop

Stop sequences. Accepts string or array of strings. Values are passed directly to upstream providers

frequency_penalty
number
default:0

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

Required range: -2 <= x <= 2
presence_penalty
number
default:0

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

Required range: -2 <= x <= 2
repetition_penalty
number

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

Required range: -2 <= x <= 2
top_k
integer

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

top_a
number

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

min_p
number

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

Required range: 0 <= x <= 1
tfs
number

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

Required range: 0 <= x <= 1
eta_cutoff
number

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

epsilon_cutoff
number

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

typical_p
number

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

Required range: 0 <= x <= 1
mirostat_mode
enum<integer>

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

Available options:
0,
1,
2
mirostat_tau
number

Mirostat target entropy parameter. Used when mirostat_mode is enabled

mirostat_eta
number

Mirostat learning rate parameter. Used when mirostat_mode is enabled

min_tokens
integer
default:0

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

Required range: x >= 0
stop_token_ids
integer[]

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

include_stop_str_in_output
boolean
default:false

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

ignore_eos
boolean
default:false

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

no_repeat_ngram_size
integer

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

Required range: x >= 0
custom_token_bans
integer[]

List of token IDs to fully block

logit_bias
object

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

logprobs

When true or a number, forwards the request to providers that support returning token-level log probabilities

prompt_logprobs
boolean

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

seed
integer

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.

Response

Text completion response

id
string

Unique identifier for the completion

object
string

Object type, always 'text_completion'

created
integer

Unix timestamp of when the completion was created

model
string

Model used for completion

choices
object[]

Array of completion choices

usage
object