Cost and credit
What does a run cost?
What does a run cost?
ceil(17.304) + ceil(0.966) = 18 + 1 = 19 micro-USD, which is $0.000019. The response reports it:Is there free credit?
Is there free credit?
Why was my run refused with 402 when I still have credit?
Why was my run refused with 402 when I still have credit?
402 insufficient_credits. So a run needs at least $0.02 of available credit to start, even though it then costs much less. The refused request stored nothing, so you can retry it with the same Idempotency-Key after adding credit. See Handling insufficient credits.Am I charged for runs that fail or for retries?
Am I charged for runs that fail or for retries?
- A run that fails before a model served it, such as
503 no_route_availableor503 decision_unavailable, has its hold released and is not charged. - A run that fails after a model served it is settled as
failedat the cost it consumed.503 provider_malformed_responseis one example: the model call is billed. - A replay, meaning the same
Idempotency-Keywith the same body, is never charged again.
How do I add credit?
How do I add credit?
POST /v1/billing/checkout and an amount between 1,000 in whole cents. You finish on a Stripe-hosted checkout page, and the credit arrives once the payment succeeds. Auto-recharge can top up your balance when it falls below a threshold you set. See Credits and billing and Auto-recharge.Where do I see what I have spent?
Where do I see what I have spent?
usage and cost_micros. For totals, use GET /v1/usage for a window (the current UTC month by default), GET /v1/usage/daily for one row per day, and GET /v1/usage/ledger for one entry per model call. All three need the usage_read scope. The console also has a Usage page. See Usage reporting.The model
Which model answers my runs?
Which model answers my runs?
neon-1.1 and neon-latest, and neon-latest resolves to Neon 1.1. You can pass either as the optional model field on a decision run; any other value is refused with 400 unknown_model. Leave model out and the run uses Neon 1.1. Live decision responses report decision.model as neon-1.1, and usage ledger entries show model_id: "neon-1.1" and provider: "opentype". See Models and pricing.Why does my verdict run return 503?
Why does my verdict run return 503?
kind, has no model to route to and answers 503 no_route_available every time, so retrying does not help. Send "kind": "decision" with a state and questions instead: a verdict schema with an enum usually maps to a single choice question. See Verdict runs and Decision runs.How much input can a run take?
How much input can a run take?
ceil(state bytes / 4) + ceil(contract bytes / 4), where the contract is your instructions, questions, draws and think_tokens. Above that, the run is refused with 413 input_too_large. The request body is capped at 4 MiB. See Limits.How many questions can one run ask?
How many questions can one run ask?
instructions, draws and think_tokens must fit in 32 KiB, and the whole input must still fit the 262,144-token context. Keep every option and level name to a single short word: long labels fail at routing time with 503 decision_unavailable. See Decision questions.Limits
What are the rate limits?
What are the rate limits?
429 responses come from POST /v1/runs, and they are quota refusals:organization_spend_quota_exhausted: the per-request ceiling, at most 20,000 micro-USD, is more than the spend left in your organization’s period limit.organization_token_quota_exhausted: the estimated input tokens plusmax_output_tokensare more than the tokens left in the period.
GET /v1/quota shows the limits and what remains; a null limit means there is none. See Spend limits and quotas.Is there a limit on parallel requests?
Is there a limit on parallel requests?
How long can a run take?
How long can a run take?
deadline_ms. A decision run defaults to 30,000 plus 120,000 per 262,144 input tokens, and any value is clamped to 1 to 150,000. A run that passes its deadline fails with 504 deadline_exceeded. Set your HTTP client timeout above deadline_ms, at least 160 seconds. See Limits.API keys
Do API keys expire?
Do API keys expire?
DELETE /v1/keys/{key_id}, or Revoke in the console) is permanent: the key stops authenticating on its next request with 401 invalid_credential, and it stays listed as an audit trail. Plan your own rotation schedule instead. See API key security.How do I rotate a key?
How do I rotate a key?
POST /v1/keys/{key_id}/rotate, with a key that holds keys_write, returns the same key id, name and scopes with a new secret, shown once. The old secret stops working immediately, with no grace period, so every process using it fails until it has the new one. A revoked key cannot be rotated (409 key_revoked).For a change with no downtime, overlap two keys instead: create a new key, deploy it everywhere, then revoke the old one. See Key rotation.I lost a key secret. Can I get it back?
I lost a key secret. Can I get it back?
Which scopes does my key need?
Which scopes does my key need?
runs_write and runs_read, the Send requests set in the console. Add usage_read for usage and quota, and billing_read for the balance. A key’s scopes are fixed when you create it, and you can only give it scopes you hold yourself. See Scopes.Requests and responses
My request timed out. Where do I find the answer?
My request timed out. Where do I find the answer?
POST /v1/runs is synchronous: it returns once the run has settled. If your client gave up first, the run may still have completed. Do not send it again with a new Idempotency-Key, which would start a second, separately charged run. Instead:- Replay the same request, with the same
Idempotency-Keyand the same body. A completed run comes back as200with its answer and"replayed": true, and it is not charged again. A run that is not finished comes back as202with"state": "pending". - Read it by id with
GET /v1/runs/{run_id}(scoperuns_read). A completed run carries itsdecision,usageandcost_micros. - If the run is still
pendingafter its deadline has passed (at most 150 s), it failed before a model served it and will not finish. Send the request again with a new key.
run_id as well, GET /v1/runs?limit=5 lists your newest runs first.GET and replays leave out cost_basis, and a decision read this way has no model, stages or thought fields. See Polling.Can I stream the answer token by token?
Can I stream the answer token by token?
GET /v1/runs/{run_id}/stream returns server-sent events, but it is a one-shot snapshot of the stored run: a state event, then a terminal event if the run is completed or failed (a completed run’s carries the answer), and then the connection closes. It does not wait for a pending run, it sends no partial answers, and it does not support Last-Event-ID for resuming. To follow a run, request it again or poll GET /v1/runs/{run_id}. See Streaming.Do I have to send an Idempotency-Key?
Do I have to send an Idempotency-Key?
POST /v1/runs: without one the request is refused with 400 idempotency_key_required. A key is 1 to 255 bytes, unique within your organization, and never expires. Reuse it when you retry the same request, and use a new one for a new request: the same key with a different body answers 409 idempotency_conflict. Keys built from your own ids work well, such as ticket-4822-triage. See Idempotency.Which errors should I retry?
Which errors should I retry?
500, 503 and 504 with backoff and a new Idempotency-Key. Retry 402 after adding credit and 429 after the quota period resets, both with the same key. Fix any other 4xx before sending again. Responses carry no retry hint, so decide from the status and error.code, and log the x-request-id of every failure. See Error handling and Troubleshooting.Related
- Troubleshooting - symptom, cause and fix for the errors you are most likely to meet.
- Glossary - what
noul, hold, period, stage and the other terms mean. - Models and pricing - Neon 1.1, its context, and the cost arithmetic in full.
- Runs - run states, replays, and what a run returns.
- Problem codes - every error code with its own page.