Quickstart
- Open the dashboard, create an API key, and save it as
EPOCH_API_KEYin your server environment. Copy it when it’s created and keep it out of browser code and source control. - Check your available credits. New accounts start at zero. You can list models with a key before you have credits, but inference requires enough to cover the request’s hold.
- Use model discovery to choose an exact ID, then replace
YOUR_MODEL_IDin the example. For the Python or TypeScript sample, install theopenaiSDK first.
curl 'https://api.epochllm.ai/v1/chat/completions' \
-H "Authorization: Bearer $EPOCH_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{"role":"user","content":"Explain token billing in one sentence."}
]
}'Use the EpochLLM origin for HTTP requests and append /v1 for the OpenAI SDK base URL. Send Authorization: Bearer <key> and use Content-Type: application/json for request bodies. Anthropic Messages also accepts x-api-key if you omit Authorization.
Models and quotes
Browse models and provider availability, or use the authenticated endpoints below to choose a model in code. The catalog can show reference-only models. Discover models through the API before sending requests.
export EPOCH_ORIGIN='https://api.epochllm.ai'
curl "$EPOCH_ORIGIN/v1/models?type=text" \
-H "Authorization: Bearer $EPOCH_API_KEY"
curl "$EPOCH_ORIGIN/v1/prices" \
-H "Authorization: Bearer $EPOCH_API_KEY"GET /v1/models- Returns an OpenAI-style list under
data. It includes configured chat models, live text models with billable quotes, and media models when enabled. Filter bytype=textortype=image,video,music; media also supportsmodality, such astext->video. GET /v1/prices- Returns
currency: "USD"and adataobject keyed by live text model ID. Each quote containsdiscount_pctand current and original input/output rates. For example,input_micro_per_million: 400000means $0.40 per million input tokens.
EpochLLM refreshes live text quotes every 20 seconds and stops using a snapshot after 60 seconds. When prices are unavailable, /v1/prices may return an empty data object and live text inference returns market_prices_unavailable. Configured chat models have fixed rates and do not depend on the live feed.
Text API
All inference routes below use POST. Configured chat models support Chat Completions only; the other routes need a compatible live text model. Parameters and model capabilities vary by route.
| Endpoint | Use | Output limit |
|---|---|---|
/v1/chat/completions | OpenAI-style messages | max_completion_tokens or max_tokens |
/v1/completions | Single text prompt | max_tokens |
/v1/responses | Text Responses API | max_output_tokens |
/anthropic/v1/messages | Anthropic-style messages | max_tokens |
/v1/decisions | Decision requests; input-only billing, no streaming | None |
Send one completion per request. Live text supports text inputs and model-compatible client-side function calling. It does not support hosted tools, multimodal inputs, background execution, or stored responses. For Responses, EpochLLM sets store: false. Configured chat models accept plain text from system, user, and assistant only.
The request body limit is 256 KiB for live text and 64 KiB for configured chat models. When you omit an output limit, live text defaults to up to 1,024 tokens and configured chat to up to 512, capped by the model. Decisions has no output-token charge.
Discounts and routing
A minimum discount tells EpochLLM when to reject a live text request instead of running it. Send X-Min-Discount: 60, or use /min60/v1/chat/completions. For Anthropic Messages, use /anthropic/min60/v1/messages.
curl "$EPOCH_ORIGIN/min60/v1/chat/completions" \
-H "Authorization: Bearer $EPOCH_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"YOUR_LIVE_TEXT_MODEL_ID",
"messages":[{"role":"user","content":"Say hello."}],
"max_completion_tokens":256}'Floors are integers from 0 to 100, though customer discounts above 90% aren’t attainable. If you use both forms, the higher floor wins. With neither form, there’s no routing minimum. If no eligible provider can meet a requested floor, the request returns minimum_discount_not_met. The /min{N}/v1/models and /min{N}/v1/prices aliases do not filter results by discount.
Provider preferences
For live text, send provider preferences in the request body. Use provider to restrict providers, providers_blocked to exclude them, and provider_order or si_route for route preferences. provider_url and provider_base_url match existing routes; they don’t let you choose an arbitrary destination.
The gateway also accepts X-SI-Route-Objective (for example, latency) and X-SI-Route-Tolerance-Pct. Narrower preferences can leave no eligible provider at your floor. min_privacy and X-SI-Mask-Secrets depend on route availability. Check X-SI-Privacy-Level or X-SI-Secret-Masking when present, and never send secrets assuming masking will apply. Fixed-rate chat models don’t support these controls.
Pricing and settlement
Catalog rates estimate what you’ll pay at the best advertised offer. Your final charge uses the offer that serves your request, keeping 10 percentage points of its discount for EpochLLM. A 40% offer appears as 30% off. If the actual offer gives 35% off, you pay 25% off unless you requested a higher minimum.
Worked example: 80% off
Illustrative direct rates of $2 input and $8 output per million become $0.40 input and $1.60 output. A request using 1,000 input tokens and 250 output tokens costs:
$0.0004 input + $0.0004 output = $0.0008That is 800 micro-USD. One USD equals 1,000,000 micro-USD. EpochLLM rounds the combined request charge up to the next whole micro-USD when needed.
Quote, reserve, settle
- Reserve credits. Before sending a request, EpochLLM holds enough credits to cover estimated input and the allowed output at direct rates. A tighter output limit can reduce the hold.
- Charge the actual offer. EpochLLM verifies the usage and offer cost, applies its margin without exceeding the direct price or violating your minimum discount, and releases unused credits. A definitive rejection releases the whole hold. If the amount can’t be verified, the hold stays pending.
Read the charge from the response
For live text, X-Epoch-Request-Id identifies the request. The fields below show the actual settlement. Check the dashboard for settled usage and available credits.
X-Epoch-Discount-Pct- Final discount when the direct cost is known and nonzero.
X-Epoch-Cost-Micro- Final customer charge in micro-USD, when settlement succeeds.
X-Epoch-Settlementsettledmeans the charge was recorded.pendingmeans it could not yet be verified. On a stream, the settlement, charge, and discount are HTTP trailers when your connection exposes them.
Catalog discount history and provider performance describe the marketplace. The 24-hour request and spend totals come from settled activity in EpochLLM’s own ledger.
Streaming
Set stream: true and read server-sent events (SSE) instead of a single JSON response. Decisions does not stream. Live Chat Completions and Completions automatically request a usage event; configured chat returns usage to the caller only with stream_options: {"include_usage": true}.
curl -N "$EPOCH_ORIGIN/v1/chat/completions" \
-H "Authorization: Bearer $EPOCH_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"YOUR_MODEL_ID","stream":true,
"stream_options":{"include_usage":true},
"messages":[{"role":"user","content":"Say hello."}]}'Read through the terminal event. For live text, partial output or a dropped connection does not prove that a request went unbilled. A stream that began with HTTP 200 can still end with an SSE error event carrying settlement_pending. Save the request ID and check the original request before retrying.
Images, video, and music
Where media is enabled, use GET /v1/models?type=image,video,music and select a model matching the requested modality. Images return synchronously. Video and music return a job that you poll.
| Endpoint | Result |
|---|---|
POST /v1/images/generations | 200 with image data. Use response_format: url or b64_json where supported. |
POST /v1/images/edits | 200 with edited image data. Send JSON with the source image fields supported by your model. |
POST /v1/{video,music}/generations | 202 with an ID, poll URL, cancel URL, job token, and cost fields. |
GET /v1/{video,music}/generations/{id} | 200 with the job status and any results. Check status even on HTTP 200. |
DELETE /v1/{video,music}/generations/{id} | Requests cancellation. Poll again to see the final state. |
GET /v1/media/artifacts/{id}/{index} | Returns the artifact or redirects to an expiring HTTPS download. |
Submit once, then poll
curl "$EPOCH_ORIGIN/v1/video/generations" \
-H "Authorization: Bearer $EPOCH_API_KEY" \
-H "Idempotency-Key: $MEDIA_REQUEST_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"YOUR_VIDEO_MODEL_ID",
"prompt":"Clouds drifting above a green hillside"}'
# Set POLL_PATH to the poll_url from the 202 response.
curl "$EPOCH_ORIGIN$POLL_PATH" \
-H "Authorization: Bearer $EPOCH_API_KEY"Set MEDIA_REQUEST_KEY to a new unique value for each new job. When retrying the same video or music submission, reuse the original key, payload, discount floor, and submitting API key. A conflicting payload returns idempotency_key_reused. If the first submission cannot be confirmed, the same key returns submission_unconfirmed.
Poll, cancel, and download with the submitting API key or X-Job-Token. Keep the token secret. If an artifact endpoint redirects to storage, make a separate request to the destination without the API key or job token. Download promptly because result links can expire.
Media charges
Media does not use the text discount formula. EpochLLM holds a configured maximum for the media type, then charges the confirmed media cost up to that ceiling without adding a markup. Async max_cost_usdc is the hold in micro-USD. The estimate and catalog reference price are not final charges. Failed, canceled, or expired jobs release the hold; an unverified cost can leave it pending even when a result is visible.
For media submissions, a minimum discount gates the estimated marketplace offer, not the final charge. Use the header or path prefix on submission only. Media does not accept text routing or masking controls. The gateway accepts up to 40 MiB of media JSON; a deployment proxy may impose a lower limit.
Errors and retries
For JSON errors, inspect error.code as well as the HTTP status. Log the model ID, status, and X-Epoch-Request-Id when present. Don’t log keys or job tokens.
| HTTP | Error code | What to do |
|---|---|---|
| 400 | unsupported_request | Check the payload, supported tools, and endpoint-specific token limit. |
| 400 | invalid_minimum_discount | Send one whole number from 0 to 100. |
| 401 | invalid_api_key | Use an active EpochLLM key. Create or replace it in the dashboard. |
| 402 | insufficient_credit / insufficient_quota | Check available credits and reduce the output limit if appropriate. |
| 404 | model_not_available / model_not_found | Refresh the model list; a catalog entry may not be routable. |
| 404 | minimum_discount_not_met | Check the current quote and eligible providers. Lower the floor only if you accept a smaller discount. |
| 409 | submission_unconfirmed | For a media job, keep the original idempotency key and check the prior submission. Do not generate a new key blindly. |
| 413 / 415 | body_too_large / invalid_content_type | Send JSON within the route’s body limit. |
| 429 | rate_limit_exceeded | Back off and honor Retry-After when present. |
| 502 | settlement_pending | Save X-Epoch-Request-Id and check the original request before retrying. |
| 503 | market_prices_unavailable | The live text quote is stale or missing. Refresh prices after a short wait. |
Live text does not support Idempotency-Key. When the result or charge is uncertain, check the original request rather than assuming a retry will replace it.