GET /api/v1/usage/requests/{request_id} returns the recorded cost and token
usage for one primary charge from the last 24 hours. Capture X-Request-ID
from the inference response headers before reading SSE and use the same API
key for the lookup. No dates or other query parameters are accepted.For chat completions, omit the incoming X-Request-ID header and capture the
server-generated ID from each response. Save it as soon as the response headers
arrive, before consuming the stream; it is the ID to use for this lookup.
cost is the exact amount recorded on the matching primary charge, expressed
as a decimal string in currency (USD or XNO). The lookup does not
recalculate prices. A recorded zero is returned as zero; a missing charge is
never converted to zero.Refunds and separately billed extras, such as a separate search charge, are
excluded. Components already incorporated in the primary charge’s amount remain
included. This is the original recorded primary cost, not an all-in total or a
net amount after refunds. A later refund does not reduce this field. A completed
transaction record is also not proof that balance collection has finished.Tokens are recorded accounting values and may have been estimated for an
interrupted stream. Missing, invalid or unsafe-sized counts are null.
Reasoning tokens may already be included in output tokens; do not add them again.
No prompts, responses, provider routing, internal identifiers or arbitrary
transaction metadata are returned.
The window is rolling, including across UTC midnight. A charge is eligible when
its accounting timestamp is no more than the database’s current time and is
strictly less than 24 hours old. expires_at is that timestamp plus 24 hours;
access ends at that instant. This timestamp can precede insertion when delayed
billing is replayed. Replay does not reset the lookup window. Financial records
are retained; this endpoint simply stops exposing older charges.Billing can be asynchronous, especially after a disconnect, so the charge might
not be available immediately. A charge recorded only after its window expires
cannot be recovered through this endpoint. Expired, unavailable and inaccessible
records all return the same 404; this does not prove that a request was free.If you supply your own X-Request-ID, use a unique value for every execution,
including a retry that sends a new inference request. The header is a correlation
ID, not an idempotency key: reusing it does not prevent another charge. After a
disconnect, look up the original ID to recover its cost; retrying the lookup does
not rerun inference. If you also retry inference, keep the two execution IDs
separate. If more than one eligible primary charge matches within the window,
the endpoint returns 409 ambiguous_request_id, without choosing one,
summing different attempts, or returning their details. Uniqueness is checked
within the window only; reusing an expired ID can resolve to a newer execution.
Only completed primary charges with the exact stored public request ID are
covered. Other endpoints are supported only when they persist that identity and
key/issuer attribution. Related child IDs and archived records are not followed.
The inference key can read only its own charges attributed to its originating
account in the same NanoGPT tenant. Team-paid charges remain visible to the originating actor’s
key; team ownership or membership does not grant broader access. Missing or
inconsistent historical attribution can make a charge unavailable.Revoked/expired keys, deleted/merged issuers, and different keys cannot retrieve
the original key’s charges. Rotation does not transfer access. Authentication is
fresh and existing key Origin restrictions apply. Use Authorization or
x-api-key; cookies, management credentials and partner tokens grant no access.
Conflicting credentials are rejected; equivalent supported prefix/case forms
are accepted.
Make the first lookup about two seconds after a disconnect or completion. A 404
includes Retry-After: 30: wait at least 30 seconds, plus a small random
delay, before the next lookup. Honor Retry-After on 429 and 503 responses too;
do not cap a larger server-requested delay at 30 seconds. For a network failure
without a response, back off with jitter from two seconds up to 30 seconds.Stop on 200. Stop and correct the request or seek support on 400, 401, 403 or 409;
do not automatically rerun inference to resolve a billing lookup error. This API
does not expose a finalized flag and clients do not need to keep polling for
later refunds. Clients are responsible for polling and honoring retry delays.The shared budgets are 60 lookups/minute per key and 300/minute per trusted
IP, including unsuccessful lookups. Coordinate polling across concurrent
requests. If no charge appears, stop retries no later than 24 hours after the
original request and retain its ID for support. This is a retry limit, not a
promise that every billing record will become available within 24 hours.
Status
Meaning
200
One recorded primary charge, with exact cost, currency, tokens and expiry.
400
Invalid request ID, unsupported query parameters, or conflicting credentials.
401 / 403
Credential, issuer or key-policy rejection; stop and correct access.
404
No eligible charge visible to this key. May be delayed, expired, inaccessible or absent; never assume zero cost. Wait at least the indicated 30 seconds before retrying.
409
Multiple eligible primary charges match this ID; do not automatically retry or infer a total.
429
Quota exceeded; honor Retry-After.
503
The billing lookup is temporarily unavailable; honor Retry-After.
Every response uses Cache-Control: private, no-store, max-age=0, private/no-store
CDN headers and Vary: Authorization, x-api-key.
This JavaScript example saves the ID when the response headers arrive. Keep it
even if reading the body fails. model and messages are the values from your
normal chat request, and apiKey is your NanoGPT API key.
const response = await fetch('https://api.nano-gpt.com/api/v1/chat/completions', { method: 'POST', headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ model, messages, stream: true }),});const requestId = response.headers.get('x-request-id');// Save requestId before consuming response.body with your SSE parser.// If the stream disconnects, keep that ID and follow the polling guidance above.
Use the HTTP response header, not a completion ID from a JSON body or SSE event.
If the connection fails before headers arrive and no ID was captured, this
endpoint cannot identify that execution for you.For a later lookup, use the same key and the captured ID:
if (requestId) { const lookup = await fetch( `https://api.nano-gpt.com/api/v1/usage/requests/${encodeURIComponent(requestId)}`, { headers: { Authorization: `Bearer ${apiKey}` } }, ); if (lookup.ok) { const billing = await lookup.json(); // Preserve billing.cost as a decimal string, or use a decimal library. } else { // Handle lookup.status and lookup.headers.get('retry-after') as above. }}
Retry-After may contain seconds or an HTTP date; respect its full delay.
For aggregate spend and refunds over a date range, use Usage.
X-Request-ID captured from response headers before disconnect. Prefer omitting the incoming header so the server generates one. This is not an idempotency key: use a distinct ID for each inference execution, including retries; repeated IDs may return 409.
Required string length: 1 - 128
Pattern: ^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$
Response
One recorded primary charge from the last 24 hours. All responses use private/no-store and Vary: Authorization, x-api-key.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"NanoGPT API Documentation","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/nano-gpt/6FCMRUAo4M2hGCVC/logo/light.svg?fit=max\u0026auto=format\u0026n=6FCMRUAo4M2hGCVC\u0026q=85\u0026s=d89f6de57aa2b12dc2ea56df5d7ec9f6","dark":"https://mintcdn.com/nano-gpt/6FCMRUAo4M2hGCVC/logo/dark.svg?fit=max\u0026auto=format\u0026n=6FCMRUAo4M2hGCVC\u0026q=85\u0026s=8717638b8ac464bcb371e66f6429ec5d"},"favicon":"https://mintcdn.com/nano-gpt/1yMRHEfiogPQFOKv/favicon.ico?fit=max\u0026auto=format\u0026n=1yMRHEfiogPQFOKv\u0026q=85\u0026s=c3c8e62fe0b2e0c9b152dad359de4eae","api":{"openapi":"api-reference/openapi.json","playground":{}},"navbar":{"links":[{"href":"/volume-pricing","label":"Volume Pricing"},{"href":"mailto:support@nano-gpt.com","label":"Support"}],"primary":{"type":"button","label":"Back to NanoGPT","href":"https://nano-gpt.com"}},"footer":{"socials":{"x":"https://x.com/nanogptcom","discord":"https://discord.gg/KaQt8gPG6V","linkedin":"https://linkedin.com/company/nanogpt"}},"variables":{"example-text-model":"openai/gpt-6.1-sol","example-text-model-name":"GPT 6.1 Sol"},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"Back to NanoGPT","icon":"book-open-cover","href":"https://nano-gpt.com"},{"anchor":"Discord","icon":"discord","href":"https://discord.gg/KaQt8gPG6V"},{"anchor":"Blog","icon":"newspaper","href":"https://nano-gpt.com/blog"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"nano-gpt","hasAudioNarration":false,"actualSubdomain":"nano-gpt","customDomains":["docs.nano-gpt.com"],"gitSource":{"type":"github","owner":"nano-gpt-com","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae8bffffd92378ebc2eb408","collectionId":"899700b3-1bbd-4ae7-bf4f-099d6ab5085e","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae8bffffd92378ebc2eb408"},"entitlements":{},"buildId":"6ae8bffffd92378ebc2eb408","clientVersion":"0.0.4045","searchFilterCounts":[{"language":"default","tag":"Endpoint Examples","count":56},{"language":"default","tag":"Miscellaneous","count":31},{"language":"default","tag":"Integrations","count":25},{"language":"default","tag":"API Reference","count":11},{"language":"default","tag":"Get Started","count":4}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/endpoint/request-billing","slug":"/api-reference/endpoint/request-billing","pageMetadata":{"title":"Request Billing","openapi":"GET /v1/usage/requests/{request_id}","description":"Look up a recorded primary charge and token usage by request ID for 24 hours.","href":"/api-reference/endpoint/request-billing"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Look up a recorded primary charge and token usage by request ID for 24 hours.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[_jsx(_components.code,{children:`GET /api/v1/usage/requests/{request_id}`}),` returns the recorded cost and token\nusage for one primary charge from the `,_jsx(_components.strong,{children:`last 24 hours`}),`. Capture `,_jsx(_components.code,{children:`X-Request-ID`}),`\nfrom the inference response headers before reading SSE and use the `,_jsx(_components.strong,{children:`same API\nkey`}),` for the lookup. No dates or other query parameters are accepted.`]}),`\n`,_jsxs(_components.p,{children:[`For chat completions, omit the incoming `,_jsx(_components.code,{children:`X-Request-ID`}),` header and capture the\nserver-generated ID from each response. Save it as soon as the response headers\narrive, before consuming the stream; it is the ID to use for this lookup.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.nano-gpt.com/api/v1/usage/requests/req_example'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$NANOGPT_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`15`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"request_billing\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"request_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"req_example\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"created_at\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"2026-09-17T10:00:01.000000Z\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"expires_at\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"2026-09-18T10:00:01.000000Z\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"as_of\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"2026-09-17T10:00:05.000000Z\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"cost\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"0.00123456\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"currency\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"USD\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"cost_scope\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"primary_charge\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"usage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"input_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`123`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"output_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`45`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"reasoning_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`what-cost-means`,children:`What cost means`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`cost`}),` is the exact amount recorded on the matching primary charge, expressed\nas a decimal `,_jsx(_components.strong,{children:`string`}),` in `,_jsx(_components.code,{children:`currency`}),` (`,_jsx(_components.code,{children:`USD`}),` or `,_jsx(_components.code,{children:`XNO`}),`). The lookup does not\nrecalculate prices. A recorded zero is returned as zero; a missing charge is\nnever converted to zero.`]}),`\n`,_jsx(_components.p,{children:`Refunds and separately billed extras, such as a separate search charge, are\nexcluded. Components already incorporated in the primary charge’s amount remain\nincluded. This is the original recorded primary cost, not an all-in total or a\nnet amount after refunds. A later refund does not reduce this field. A completed\ntransaction record is also not proof that balance collection has finished.`}),`\n`,_jsxs(_components.p,{children:[`Tokens are recorded accounting values and may have been estimated for an\ninterrupted stream. Missing, invalid or unsafe-sized counts are `,_jsx(_components.code,{children:`null`}),`.\nReasoning tokens may already be included in output tokens; do not add them again.\nNo prompts, responses, provider routing, internal identifiers or arbitrary\ntransaction metadata are returned.`]}),`\n`,_jsx(Heading,{level:`2`,id:`availability-and-request-ids`,children:`Availability and request IDs`}),`\n`,_jsxs(_components.p,{children:[`The window is rolling, including across UTC midnight. A charge is eligible when\nits accounting timestamp is no more than the database’s current time and is\nstrictly less than 24 hours old. `,_jsx(_components.code,{children:`expires_at`}),` is that timestamp plus 24 hours;\naccess ends at that instant. This timestamp can precede insertion when delayed\nbilling is replayed. Replay does not reset the lookup window. Financial records\nare retained; this endpoint simply stops exposing older charges.`]}),`\n`,_jsx(_components.p,{children:`Billing can be asynchronous, especially after a disconnect, so the charge might\nnot be available immediately. A charge recorded only after its window expires\ncannot be recovered through this endpoint. Expired, unavailable and inaccessible\nrecords all return the same 404; this does not prove that a request was free.`}),`\n`,_jsxs(_components.p,{children:[`If you supply your own `,_jsx(_components.code,{children:`X-Request-ID`}),`, use a unique value for every execution,\nincluding a retry that sends a new inference request. The header is a correlation\nID, `,_jsx(_components.strong,{children:`not an idempotency key`}),`: reusing it does not prevent another charge. After a\ndisconnect, look up the original ID to recover its cost; retrying the lookup does\nnot rerun inference. If you also retry inference, keep the two execution IDs\nseparate. If more than one eligible primary charge matches within the window,\nthe endpoint returns `,_jsxs(_components.strong,{children:[`409 `,_jsx(_components.code,{children:`ambiguous_request_id`})]}),`, without choosing one,\nsumming different attempts, or returning their details. Uniqueness is checked\nwithin the window only; reusing an expired ID can resolve to a newer execution.\nOnly completed primary charges with the exact stored public request ID are\ncovered. Other endpoints are supported only when they persist that identity and\nkey/issuer attribution. Related child IDs and archived records are not followed.`]}),`\n`,_jsx(Heading,{level:`2`,id:`authentication`,children:`Authentication`}),`\n`,_jsx(_components.p,{children:`The inference key can read only its own charges attributed to its originating\naccount in the same NanoGPT tenant. Team-paid charges remain visible to the originating actor’s\nkey; team ownership or membership does not grant broader access. Missing or\ninconsistent historical attribution can make a charge unavailable.`}),`\n`,_jsxs(_components.p,{children:[`Revoked/expired keys, deleted/merged issuers, and different keys cannot retrieve\nthe original key’s charges. Rotation does not transfer access. Authentication is\nfresh and existing key Origin restrictions apply. Use `,_jsx(_components.code,{children:`Authorization`}),` or\n`,_jsx(_components.code,{children:`x-api-key`}),`; cookies, management credentials and partner tokens grant no access.\nConflicting credentials are rejected; equivalent supported prefix/case forms\nare accepted.`]}),`\n`,_jsx(Heading,{level:`2`,id:`polling-and-errors`,children:`Polling and errors`}),`\n`,_jsxs(_components.p,{children:[`Make the first lookup about two seconds after a disconnect or completion. A 404\nincludes `,_jsx(_components.code,{children:`Retry-After: 30`}),`: wait `,_jsx(_components.strong,{children:`at least 30 seconds`}),`, plus a small random\ndelay, before the next lookup. Honor `,_jsx(_components.code,{children:`Retry-After`}),` on 429 and 503 responses too;\ndo not cap a larger server-requested delay at 30 seconds. For a network failure\nwithout a response, back off with jitter from two seconds up to 30 seconds.`]}),`\n`,_jsxs(_components.p,{children:[`Stop on 200. Stop and correct the request or seek support on 400, 401, 403 or 409;\ndo not automatically rerun inference to resolve a billing lookup error. This API\ndoes not expose a `,_jsx(_components.code,{children:`finalized`}),` flag and clients do not need to keep polling for\nlater refunds. Clients are responsible for polling and honoring retry delays.`]}),`\n`,_jsxs(_components.p,{children:[`The shared budgets are `,_jsx(_components.strong,{children:`60 lookups/minute per key`}),` and `,_jsx(_components.strong,{children:`300/minute per trusted\nIP`}),`, including unsuccessful lookups. Coordinate polling across concurrent\nrequests. If no charge appears, stop retries no later than 24 hours after the\noriginal request and retain its ID for support. This is a retry limit, not a\npromise that every billing record will become available within 24 hours.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Status`}),_jsx(_components.th,{children:`Meaning`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`200`}),_jsx(_components.td,{children:`One recorded primary charge, with exact cost, currency, tokens and expiry.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`400`}),_jsx(_components.td,{children:`Invalid request ID, unsupported query parameters, or conflicting credentials.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`401 / 403`}),_jsx(_components.td,{children:`Credential, issuer or key-policy rejection; stop and correct access.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`404`}),_jsx(_components.td,{children:`No eligible charge visible to this key. May be delayed, expired, inaccessible or absent; never assume zero cost. Wait at least the indicated 30 seconds before retrying.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`409`}),_jsx(_components.td,{children:`Multiple eligible primary charges match this ID; do not automatically retry or infer a total.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`429`}),_jsxs(_components.td,{children:[`Quota exceeded; honor `,_jsx(_components.code,{children:`Retry-After`}),`.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:`503`}),_jsxs(_components.td,{children:[`The billing lookup is temporarily unavailable; honor `,_jsx(_components.code,{children:`Retry-After`}),`.`]})]})]})]}),`\n`,_jsxs(_components.p,{children:[`Every response uses `,_jsx(_components.code,{children:`Cache-Control: private, no-store, max-age=0`}),`, private/no-store\nCDN headers and `,_jsx(_components.code,{children:`Vary: Authorization, x-api-key`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`capture-the-id-before-reading-a-stream`,children:`Capture the ID before reading a stream`}),`\n`,_jsxs(_components.p,{children:[`This JavaScript example saves the ID when the response headers arrive. Keep it\neven if reading the body fails. `,_jsx(_components.code,{children:`model`}),` and `,_jsx(_components.code,{children:`messages`}),` are the values from your\nnormal chat request, and `,_jsx(_components.code,{children:`apiKey`}),` is your NanoGPT API key.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'https://api.nano-gpt.com/api/v1/chat/completions'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Authorization:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Bearer \"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`apiKey`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`model`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`stream:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` requestId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`headers`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'x-request-id'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Save requestId before consuming response.body with your SSE parser.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// If the stream disconnects, keep that ID and follow the polling guidance above.`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Use the HTTP response header, not a completion ID from a JSON body or SSE event.\nIf the connection fails before headers arrive and no ID was captured, this\nendpoint cannot identify that execution for you.`}),`\n`,_jsx(_components.p,{children:`For a later lookup, use the same key and the captured ID:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`requestId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` lookup`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://api.nano-gpt.com/api/v1/usage/requests/\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`encodeURIComponent`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`requestId`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Authorization:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `Bearer \"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`apiKey`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` );`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`lookup`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ok`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` billing`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` lookup`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Preserve billing.cost as a decimal string, or use a decimal library.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`else`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Handle lookup.status and lookup.headers.get('retry-after') as above.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`Retry-After`}),` may contain seconds or an HTTP date; respect its full delay.\nFor aggregate spend and refunds over a date range, use `,_jsx(_components.a,{href:`/api-reference/endpoint/usage`,children:`Usage`}),`.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Request Billing","openapi":"GET /v1/usage/requests/{request_id}","description":"Look up a recorded primary charge and token usage by request ID for 24 hours.","href":"/api-reference/endpoint/request-billing"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"What cost means","slug":"what-cost-means","depth":2,"children":[]},{"title":"Availability and request IDs","slug":"availability-and-request-ids","depth":2,"children":[]},{"title":"Authentication","slug":"authentication","depth":2,"children":[]},{"title":"Polling and errors","slug":"polling-and-errors","depth":2,"children":[]},{"title":"Capture the ID before reading a stream","slug":"capture-the-id-before-reading-a-stream","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/nano-gpt/4d1e35af7642852b/copy-markdown.js"],"openApiReferenceData":{"operation":{"operationId":"retrieveRequestBilling","tags":["Account"],"summary":"Retrieve a recorded primary request charge","description":"Look up a recorded primary charge and token usage by request ID for 24 hours.","parameters":["0e20e5cb-4617-45f4-92bb-5770ce26733c"],"responses":{"200":"f4b47be4-1435-4024-a213-345da48a6674","400":"81b727de-1d9c-4520-98f9-d3177e80633e","401":"ee78bbd7-81c5-4cdf-b168-e7b5b5a43173","403":"fd49db95-2e5f-4aad-aa89-e2b8ad73950d","404":"fb32bd4f-267b-452f-9a8d-a4e0fd2964ea","409":"194ed765-f908-4071-a880-8c8f61865b89","429":"90a567d7-9896-4481-85eb-cfdb66fc6267","503":"96c64498-45f6-4bcc-82b3-e5cfe346d81f"},"security":["f0776008-2872-44b1-960b-5abc7619b5e2","bccd4671-7ec0-4dbd-b514-a67303d934d9"],"method":"get","type":"path","servers":["e4fbf8d5-2743-43e4-8391-a3ad5d0c8001","7780f14e-12b2-456c-92eb-0cf435ee123d"],"path":"/v1/usage/requests/{request_id}","baseUrlOptions":["https://api.nano-gpt.com/api","https://nano-gpt.com/api"],"title":"Retrieve a recorded primary request charge","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{"0e20e5cb-4617-45f4-92bb-5770ce26733c":{"name":"request_id","in":"path","required":true,"description":"X-Request-ID captured from response headers before disconnect. Prefer omitting the incoming header so the server generates one. This is not an idempotency key: use a distinct ID for each inference execution, including retries; repeated IDs may return 409.","schema":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$","isRequired":true,"description":"X-Request-ID captured from response headers before disconnect. Prefer omitting the incoming header so the server generates one. This is not an idempotency key: use a distinct ID for each inference execution, including retries; repeated IDs may return 409.","uniqueKey":"","typeLabel":"string"}}},"responses":{"f4b47be4-1435-4024-a213-345da48a6674":{"description":"One recorded primary charge from the last 24 hours. All responses use private/no-store and Vary: Authorization, x-api-key.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["object","request_id","created_at","expires_at","as_of","cost","currency","cost_scope","usage"],"properties":{"object":{"type":"string","const":"request_billing","isRequired":true,"uniqueKey":"object","typeLabel":"string"},"request_id":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$","isRequired":true,"uniqueKey":"request_id","typeLabel":"string"},"created_at":{"type":"string","format":"date-time","description":"Ledger accounting timestamp; not necessarily insertion time.","isRequired":true,"uniqueKey":"created_at","typeLabel":"string\u003cdate-time>"},"expires_at":{"type":"string","format":"date-time","description":"24 hours after the charge accounting timestamp. The record is unavailable at or after this instant; financial records are retained.","isRequired":true,"uniqueKey":"expires_at","typeLabel":"string\u003cdate-time>"},"as_of":{"type":"string","format":"date-time","description":"Database statement snapshot time.","isRequired":true,"uniqueKey":"as_of","typeLabel":"string\u003cdate-time>"},"cost":{"type":"string","pattern":"^\\d{1,80}(?:\\.\\d{1,40})?$","maxLength":121,"description":"Exact nonnegative amount recorded on the primary charge. Does not subtract refunds or add separately billed extras; not proof of balance collection.","isRequired":true,"uniqueKey":"cost","typeLabel":"string"},"currency":{"type":"string","enum":["USD","XNO"],"isRequired":true,"uniqueKey":"currency","typeLabel":"enum\u003cstring>"},"cost_scope":{"type":"string","const":"primary_charge","isRequired":true,"uniqueKey":"cost_scope","typeLabel":"string"},"usage":{"type":"object","additionalProperties":false,"required":["input_tokens","output_tokens","reasoning_tokens"],"properties":{"input_tokens":{"oneOf":[{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Recorded accounting count, possibly estimated. Null preserves absent, invalid or unsafe-sized values.","isRequired":true,"uniqueKey":"usage.input_tokens.oneOf.0","typeLabel":"integer"},{"type":"null","minimum":0,"maximum":9007199254740991,"description":"Recorded accounting count, possibly estimated. Null preserves absent, invalid or unsafe-sized values.","isRequired":true,"uniqueKey":"usage.input_tokens.oneOf.1","typeLabel":"null"}],"isRequired":true,"uniqueKey":"usage.input_tokens","typeLabel":"integer | null"},"output_tokens":{"oneOf":[{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Recorded accounting count, possibly estimated. Null preserves absent, invalid or unsafe-sized values.","isRequired":true,"uniqueKey":"usage.output_tokens.oneOf.0","typeLabel":"integer"},{"type":"null","minimum":0,"maximum":9007199254740991,"description":"Recorded accounting count, possibly estimated. Null preserves absent, invalid or unsafe-sized values.","isRequired":true,"uniqueKey":"usage.output_tokens.oneOf.1","typeLabel":"null"}],"isRequired":true,"uniqueKey":"usage.output_tokens","typeLabel":"integer | null"},"reasoning_tokens":{"oneOf":[{"type":"integer","minimum":0,"maximum":9007199254740991,"description":"Recorded accounting count, possibly estimated. Null preserves absent, invalid or unsafe-sized values.","isRequired":true,"uniqueKey":"usage.reasoning_tokens.oneOf.0","typeLabel":"integer"},{"type":"null","minimum":0,"maximum":9007199254740991,"description":"Recorded accounting count, possibly estimated. Null preserves absent, invalid or unsafe-sized values.","isRequired":true,"uniqueKey":"usage.reasoning_tokens.oneOf.1","typeLabel":"null"}],"isRequired":true,"uniqueKey":"usage.reasoning_tokens","typeLabel":"integer | null"}},"isRequired":true,"uniqueKey":"usage","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"object":"request_billing","request_id":"req_example","created_at":"2026-09-17T10:00:01.000000Z","expires_at":"2026-09-18T10:00:01.000000Z","as_of":"2026-09-17T10:00:05.000000Z","cost":"0.00123456","currency":"USD","cost_scope":"primary_charge","usage":{"input_tokens":123,"output_tokens":45,"reasoning_tokens":null}},"examples":{"Example":{"title":"Example","value":{"object":"request_billing","request_id":"req_example","created_at":"2026-09-17T10:00:01.000000Z","expires_at":"2026-09-18T10:00:01.000000Z","as_of":"2026-09-17T10:00:05.000000Z","cost":"0.00123456","currency":"USD","cost_scope":"primary_charge","usage":{"input_tokens":123,"output_tokens":45,"reasoning_tokens":null}}}},"exampleType":"examples"}},"exampleType":"examples"},"81b727de-1d9c-4520-98f9-d3177e80633e":{"description":"Invalid request ID, unsupported query parameters, or conflicting credentials.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"ee78bbd7-81c5-4cdf-b168-e7b5b5a43173":{"description":"Missing or invalid inference API key or originating account.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"fd49db95-2e5f-4aad-aa89-e2b8ad73950d":{"description":"API key policy rejects access.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"fb32bd4f-267b-452f-9a8d-a4e0fd2964ea":{"description":"No eligible charge is visible to this key. It may be delayed, expired, inaccessible, or absent; never assume zero cost.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"headers":{"Retry-After":{"description":"Wait at least this delay before retrying. A 404 returns 30 seconds; honor larger delays too.","schema":{"type":"string"},"example":"30"}},"exampleType":"generated"},"194ed765-f908-4071-a880-8c8f61865b89":{"description":"Multiple eligible primary charges match: ambiguous_request_id. No charge is selected or summed.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"90a567d7-9896-4481-85eb-cfdb66fc6267":{"description":"Lookup rate limit exceeded. Honor Retry-After.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"headers":{"Retry-After":{"description":"Wait at least this delay before retrying. A 404 returns 30 seconds; honor larger delays too.","schema":{"type":"string"},"example":"30"}},"exampleType":"generated"},"96c64498-45f6-4bcc-82b3-e5cfe346d81f":{"description":"Billing lookup temporarily unavailable. Honor Retry-After.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","uniqueKey":"error.code","typeLabel":"string"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"headers":{"Retry-After":{"description":"Wait at least this delay before retrying. A 404 returns 30 seconds; honor larger delays too.","schema":{"type":"string"},"example":"30"}},"exampleType":"generated"}},"security":{"f0776008-2872-44b1-960b-5abc7619b5e2":{"bearerAuth":{"type":"http","scheme":"bearer","scopes":[],"schemeName":"bearerAuth"}},"bccd4671-7ec0-4dbd-b514-a67303d934d9":{"apiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","scopes":[],"schemeName":"apiKeyAuth"}}},"servers":{"e4fbf8d5-2743-43e4-8391-a3ad5d0c8001":{"url":"https://api.nano-gpt.com/api","description":"Direct API for uploads and long-running requests; choose a model listed by this host"},"7780f14e-12b2-456c-92eb-0cf435ee123d":{"url":"https://nano-gpt.com/api","description":"Website API for current text model examples"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","scopes":[],"schemeName":"bearerAuth"},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"Bearer authentication header of the form `Bearer \u003ctoken>`, where `\u003ctoken>` is your auth token.","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"},{"schemes":[{"scheme":{"type":"apiKey","in":"header","name":"x-api-key","scopes":[],"schemeName":"apiKeyAuth"},"schema":{"title":"x-api-key","type":"string","isRequired":true,"typeLabel":"string","deprecated":false},"schemeName":"apiKeyAuth","name":"x-api-key"}],"title":"apiKeyAuth"}]},"originalFileLocation":"api-reference/openapi.json"},"subdomain":"nano-gpt","siteName":"NanoGPT API Documentation","title":"Request Billing - NanoGPT API Documentation","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-23T19:31:02.170Z","originalFileLocation":"api-reference/endpoint/request-billing.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Look up a recorded primary charge and token usage by request ID for 24 hours.\">\u003cmeta data-mint-head name=\"application-name\" content=\"NanoGPT API Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Request Billing - NanoGPT API Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Look up a recorded primary charge and token usage by request ID for 24 hours.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"NanoGPT API Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://nano-gpt.mintlify.app/_mintlify/api/og/v2?division=Endpoint+Examples\u0026amp;title=Request+Billing\u0026amp;description=Look+up+a+recorded+primary+charge+and+token+usage+by+request+ID+for+24+hours.\u0026amp;theme=1b39c6cf2fbbf04ee92c37b5\u0026amp;signature=985112f0d77458d5e9b2a08b5aabc5b4052b4c5ad5e7abbf9754f683e0b9659a\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Request Billing - NanoGPT API Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Look up a recorded primary charge and token usage by request ID for 24 hours.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://nano-gpt.mintlify.app/_mintlify/api/og/v2?division=Endpoint+Examples\u0026amp;title=Request+Billing\u0026amp;description=Look+up+a+recorded+primary+charge+and+token+usage+by+request+ID+for+24+hours.\u0026amp;theme=1b39c6cf2fbbf04ee92c37b5\u0026amp;signature=985112f0d77458d5e9b2a08b5aabc5b4052b4c5ad5e7abbf9754f683e0b9659a\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/nano-gpt/ojaWxmEVE943ykND/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"NanoGPT API Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/endpoint/request-billing.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.nano-gpt.com/#organization\",\"name\":\"NanoGPT API Documentation\",\"url\":\"https://docs.nano-gpt.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/nano-gpt/6FCMRUAo4M2hGCVC/logo/light.svg?fit=max\u0026auto=format\u0026n=6FCMRUAo4M2hGCVC\u0026q=85\u0026s=d89f6de57aa2b12dc2ea56df5d7ec9f6\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.nano-gpt.com#website\",\"name\":\"NanoGPT API Documentation\",\"url\":\"https://docs.nano-gpt.com\",\"publisher\":{\"@id\":\"https://docs.nano-gpt.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing#webpage\",\"url\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing\",\"name\":\"Request Billing\",\"description\":\"Look up a recorded primary charge and token usage by request ID for 24 hours.\",\"dateModified\":\"2026-09-23T19:31:02.170Z\",\"isPartOf\":{\"@id\":\"https://docs.nano-gpt.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Endpoint Examples\",\"item\":\"https://docs.nano-gpt.com/api-reference/endpoint/models\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Request Billing\",\"item\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing#apireference\",\"headline\":\"Request Billing\",\"name\":\"Request Billing\",\"description\":\"Look up a recorded primary charge and token usage by request ID for 24 hours.\",\"url\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing\",\"mainEntityOfPage\":{\"@id\":\"https://docs.nano-gpt.com/api-reference/endpoint/request-billing#webpage\"},\"dateModified\":\"2026-09-23T19:31:02.170Z\",\"publisher\":{\"@id\":\"https://docs.nano-gpt.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.nano-gpt.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"NanoGPT API Documentation\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"NanoGPT API Documentation","nav":{"global":{"anchors":[{"anchor":"Back to NanoGPT","icon":"book-open-cover","href":"https://nano-gpt.com"},{"anchor":"Discord","icon":"discord","href":"https://discord.gg/KaQt8gPG6V"},{"anchor":"Blog","icon":"newspaper","href":"https://nano-gpt.com/blog"}]},"groups":[{"group":"Get Started","pages":[{"title":"Introduction","href":"/introduction"},{"title":"Authentication","href":"/authentication"},{"title":"Quickstart","href":"/quickstart"},{"title":"Volume Pricing","href":"/volume-pricing"}]},{"group":"Endpoint Examples","pages":[{"title":"Models","openapi":"GET /v1/models","href":"/api-reference/endpoint/models"},{"title":"List Image Models","api":"GET https://api.nano-gpt.com/api/v1/images/models","href":"/api-reference/endpoint/image-api-models"},{"title":"Get Image Model Endpoints","api":"GET https://api.nano-gpt.com/api/v1/images/models/{modelId}/endpoints","href":"/api-reference/endpoint/image-api-model-endpoints"},{"title":"Image Models","api":"GET https://api.nano-gpt.com/api/v1/image-models","href":"/api-reference/endpoint/image-models"},{"title":"Video Models","api":"GET https://api.nano-gpt.com/api/v1/video-models","href":"/api-reference/endpoint/video-models"},{"title":"Audio Models","api":"GET https://api.nano-gpt.com/api/v1/audio-models","href":"/api-reference/endpoint/audio-models"},{"title":"Personalized Models","openapi":"GET /personalized/v1/models","href":"/api-reference/endpoint/personalized-models"},{"title":"Characters","openapi":"GET /v1/characters","href":"/api-reference/endpoint/characters"},{"title":"Character Models","openapi":"GET /v1/character-models","href":"/api-reference/endpoint/character-models"},{"title":"Chat Completion","openapi":"POST /v1/chat/completions","href":"/api-reference/endpoint/chat-completion"},{"title":"Batch API","href":"/api-reference/endpoint/batches"},{"title":"List Inline Batches","openapi":"GET /api/beta/batches","href":"/api-reference/endpoint/inline-batches-list"},{"title":"List All Batches","openapi":"GET /api/v1/batches","href":"/api-reference/endpoint/batches-list"},{"title":"Direct Web Search API","api":"POST https://api.nano-gpt.com/api/web","href":"/api-reference/endpoint/web-search"},{"title":"Data API","api":"GET https://api.nano-gpt.com/api/v1/data","href":"/api-reference/endpoint/data-api"},{"title":"Decisions","openapi":"POST /v1/decisions","href":"/api-reference/endpoint/decisions"},{"title":"Responses","openapi":"POST /v1/responses","href":"/api-reference/endpoint/responses"},{"title":"Messages","openapi":"POST /v1/messages","href":"/api-reference/endpoint/messages"},{"title":"Messages Count Tokens","api":"POST https://api.nano-gpt.com/api/v1/messages/count_tokens","href":"/api-reference/endpoint/messages-count-tokens"},{"title":"Completions","openapi":"POST /v1/completions","href":"/api-reference/endpoint/completion"},{"title":"v1/audio/transcriptions (STT)","api":"POST https://api.nano-gpt.com/api/v1/audio/transcriptions","href":"/api-reference/endpoint/audio-transcriptions"},{"title":"Embeddings","openapi":"POST /v1/embeddings","href":"/api-reference/endpoint/embeddings"},{"title":"Embedding Models","openapi":"GET /v1/embedding-models","href":"/api-reference/endpoint/embedding-models"},{"title":"Generate Images","api":"POST https://api.nano-gpt.com/api/v1/images","href":"/api-reference/endpoint/image-api-generate"},{"title":"Image Generation (OpenAI-Compatible)","openapi":"POST /v1/images/generations","href":"/api-reference/endpoint/image-generation-openai"},{"title":"Image Edits","api":"POST https://api.nano-gpt.com/api/v1/images/edits","href":"/api-reference/endpoint/image-edits"},{"title":"NSFW Image Classification","openapi":"POST /nsfw/image","href":"/api-reference/endpoint/nsfw-image"},{"title":"Moderation Models","openapi":"GET /v1/moderation-models","href":"/api-reference/endpoint/moderation-models"},{"title":"Moderations","openapi":"POST /v1/moderations","href":"/api-reference/endpoint/moderations"},{"title":"AI Detection","api":"POST https://api.nano-gpt.com/api/v1/ai-detection","href":"/api-reference/endpoint/ai-detection"},{"title":"Speech-to-Text Transcription","openapi":"POST /transcribe","href":"/api-reference/endpoint/transcribe"},{"title":"Speech-to-Text Status","openapi":"POST /transcribe/status","href":"/api-reference/endpoint/transcribe-status"},{"title":"YouTube Transcription","openapi":"POST /youtube-transcribe","href":"/api-reference/endpoint/youtube-transcribe"},{"title":"Context Memory (Standalone)","openapi":"POST /v1/memory","href":"/api-reference/endpoint/memory"},{"title":"Web Scraping","openapi":"POST /scrape-urls","href":"/api-reference/endpoint/scrape-urls"},{"title":"Data Extraction APIs","api":"POST https://api.nano-gpt.com/api/v1/firecrawl","href":"/api-reference/endpoint/data-extraction"},{"title":"v1/audio/speech (TTS + Music)","api":"POST https://api.nano-gpt.com/api/v1/audio/speech","href":"/api-reference/endpoint/speech"},{"title":"Text-to-Speech","openapi":"POST /tts","href":"/api-reference/endpoint/tts"},{"title":"TTS Status","openapi":"GET /tts/status","href":"/api-reference/endpoint/tts-status"},{"title":"Voice Cloning","api":"POST https://api.nano-gpt.com/api/voice-clone/minimax","href":"/api-reference/endpoint/voice-cloning"},{"title":"TEE Attestation","openapi":"GET /v1/tee/attestation","href":"/api-reference/endpoint/tee-attestation"},{"title":"TEE Signature","openapi":"GET /v1/tee/signature/{requestId}","href":"/api-reference/endpoint/tee-signature"},{"title":"Retrieve Midjourney Generation Status","openapi":"POST /check-midjourney-status","href":"/api-reference/endpoint/check-midjourney-status"},{"title":"Video Generation","openapi":"POST /generate-video","href":"/api-reference/endpoint/video-generation"},{"title":"Video Status (Unified)","openapi":"GET /video/status","href":"/api-reference/endpoint/video-status-unified"},{"title":"Video Recover","openapi":"GET /generate-video/recover","href":"/api-reference/endpoint/video-recover"},{"title":"Video Extend","openapi":"POST /generate-video/extend","href":"/api-reference/endpoint/video-extend"},{"title":"Video Content","openapi":"GET /generate-video/content","href":"/api-reference/endpoint/video-content"},{"title":"Check Balance","openapi":"POST /check-balance","href":"/api-reference/endpoint/check-balance"},{"title":"Usage","openapi":"GET /v1/usage","description":"Retrieve aggregate spend, request, and token usage for the authenticated API key","href":"/api-reference/endpoint/usage"},{"title":"Request Billing","openapi":"GET /v1/usage/requests/{request_id}","href":"/api-reference/endpoint/request-billing"},{"title":"Feedback API","description":"Submit private API feedback and retrieve its status, with exact error codes and retry guidance.","openapi":"GET /v1/feedback/{id}","href":"/api-reference/endpoint/feedback"},{"title":"Create Invitation","openapi":"POST /invitations/create","href":"/api-reference/endpoint/invitations-create"},{"title":"Subscription Usage","openapi":"GET /subscription/v1/usage","href":"/api-reference/endpoint/subscription-usage"},{"title":"Receive Nano","openapi":"POST /receive-nano","href":"/api-reference/endpoint/receive-nano"},{"title":"Deposits (Crypto + Fiat)","api":"POST https://nano-gpt.com/api/transaction/create/{ticker}","href":"/api-reference/endpoint/crypto-deposits"}]},{"group":"API Reference","pages":[{"title":"Text Generation","href":"/api-reference/text-generation"},{"title":"Embeddings","href":"/api-reference/embeddings"},{"title":"Image API","href":"/api-reference/image-generation"},{"title":"Video Generation","href":"/api-reference/video-generation"},{"title":"Speech-to-Text (STT)","href":"/api-reference/speech-to-text"},{"title":"Text-to-Speech (TTS)","href":"/api-reference/text-to-speech"},{"title":"Music Generation","href":"/api-reference/music-generation"},{"title":"TEE Verification","href":"/api-reference/tee-verification"},{"title":"Evals and Observability","href":"/api-reference/evals"},{"title":"Teams","href":"/api-reference/teams"},{"title":"Management API","href":"/api-reference/management-api"}]},{"group":"Miscellaneous","pages":[{"title":"API Hosts","href":"/api-reference/miscellaneous/api-hosts"},{"title":"Rate Limits","href":"/api-reference/miscellaneous/rate-limits"},{"title":"Error Handling","href":"/api-reference/miscellaneous/error-handling"},{"title":"Inline Moderation","href":"/api-reference/miscellaneous/inline-moderation"},{"title":"Accountless x402 API Payments","href":"/api-reference/miscellaneous/x402"},{"title":"Extended Thinking (Reasoning)","href":"/api-reference/miscellaneous/extended-thinking"},{"title":"Change Reasoning Effort Within a Conversation","href":"/api-reference/miscellaneous/inline-reasoning-effort"},{"title":"Streaming Protocol (SSE)","href":"/api-reference/miscellaneous/streaming-protocol"},{"title":"Compressed Request Bodies","href":"/api-reference/miscellaneous/request-compression"},{"title":"Tool Calling Diagnostics","href":"/api-reference/miscellaneous/tool-calling-diagnostics"},{"title":"Hosted tool search","href":"/api-reference/miscellaneous/hosted-tool-search"},{"title":"Advisor","href":"/api-reference/miscellaneous/advisor"},{"title":"Video Input","href":"/api-reference/miscellaneous/video-input"},{"title":"Prompt Caching","href":"/api-reference/miscellaneous/prompt-caching"},{"title":"Pricing and Fees","href":"/api-reference/miscellaneous/pricing"},{"title":"Pay-As-You-Go Billing Override","href":"/api-reference/miscellaneous/billing-override"},{"title":"Provider Selection","href":"/api-reference/miscellaneous/provider-selection"},{"title":"Distillation Policy","href":"/api-reference/miscellaneous/distillation-policy"},{"title":"Model Suffixes","href":"/api-reference/miscellaneous/model-suffixes"},{"title":"PII Redaction","href":"/api-reference/miscellaneous/pii-redaction"},{"title":"OAuth PKCE","href":"/api-reference/miscellaneous/oauth-pkce"},{"title":"Brave","href":"/api-reference/miscellaneous/brave"},{"title":"Bring Your Own Key (BYOK)","href":"/api-reference/miscellaneous/byok"},{"title":"For Providers","href":"/api-reference/miscellaneous/for-providers"},{"title":"Auto Recharge","href":"/api-reference/miscellaneous/auto-recharge"},{"title":"Chrome Extension","href":"/api-reference/miscellaneous/chrome-extension"},{"title":"URL Parameters (Web App)","href":"/web-app/url-parameters"},{"title":"JavaScript Library","href":"/api-reference/miscellaneous/javascript"},{"title":"Context Memory","href":"/api-reference/miscellaneous/context-memory"},{"title":"TypeScript Library","href":"/api-reference/miscellaneous/typescript"},{"title":"Model Context Protocol (MCP)","href":"/api-reference/miscellaneous/mcp-server"}]},{"group":"Integrations","pages":[{"title":"Integrations","href":"/integrations"},{"title":"CLI Device Login","href":"/integrations/cli-login"},{"title":"Cline","href":"/integrations/cline"},{"title":"Codex CLI","href":"/integrations/codex-cli"},{"title":"Grok CLI","href":"/integrations/grok-cli"},{"title":"Gemini CLI","href":"/integrations/gemini-cli"},{"title":"Claude Code","href":"/integrations/claude-code"},{"title":"DeepSeek Harness","href":"/integrations/deepseek-harness"},{"title":"Roo Code","href":"/integrations/roocode"},{"title":"Kilo Code","href":"/integrations/kilocode"},{"title":"Cursor","href":"/integrations/cursor"},{"title":"Fluent","href":"/integrations/fluent"},{"title":"MCP","href":"/integrations/mcp"},{"title":"n8n","href":"/integrations/n8n"},{"title":"SillyTavern","href":"/integrations/sillytavern"},{"title":"RisuAI","href":"/integrations/risuai"},{"title":"OpenWebUI","href":"/integrations/openwebui"},{"title":"Otaku","href":"/integrations/otaku"},{"title":"TypingMind","href":"/integrations/typingmind"},{"title":"LibreChat","href":"/integrations/librechat"},{"title":"OpenHands","href":"/integrations/openhands"},{"title":"OpenClaw (ClawdBot)","href":"/integrations/openclaw"},{"title":"OpenCode","href":"/integrations/opencode"},{"title":"JanitorAI","href":"/integrations/janitorai"},{"title":"Droid","href":"/integrations/droid"}]}]},"basePath":"","title":"Request Billing - NanoGPT API Documentation","buildId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","deploymentId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-DCDCdBVX.js","utils-ME8dDnLe.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-0e84ACsd.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-wgRBj-ia.js","snippetPresets-C11Sgb-o.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","ApiExamples-C0lapOpP.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-ZeRQV8fF.js","shallow-BupWh095.js","getApiPlaygroundDisplay-BnYQO2Ss.js","CodeSnippet-RKKOc8c_.js","CodeSnippets-Drf_m8wS.js","Page-Bevw23-4.js","getPastedJson-u6QiPzNZ.js","icon-Bb-CBSxO.js","MethodPill-F7l5AI7V.js","DuplicateIcon-IiAXkdSg.js","createIcon-FliI8EBc.js","DynamicMarkdown-B62XqCSI.js","SectionHeading-Dj31pT03.js","axios-vUo_bRtp.js","Markdown-BOgQCTwD.js","clsx-BIWXJmsZ.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-DKZWslLH.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-UDqbR6xh.js"]}