Provider key endpoints
The Provider Market's surface: the buyer proxy that calls a provider on someone else's key, the public discovery reads, and the seller endpoints that list a key.
Base URL https://api.surplusintelligence.ai. Guides: your first call,
listing your key.
The buyer proxy
Calls {resource} on a seller's key. GET, POST and PUT are all accepted - the method and the path are
the provider's own, and what is reachable is decided per provider.
{resource} is the provider's id. Ten providers are live, and GET /api/markets/keys lists them with their ids
(see Discovery).
The path shape differs by provider. Every provider except Fal is path-style: the provider's own path goes
straight on. Fal is header-style: the path must be empty and the target rides in x-fal-target-url. A path
on Fal is refused unexpected_path.
Authenticate with your Surplus API key. The market is prepaid credit only and never falls through to the on-chain rail.
Request headers
AuthorizationstringrequiredBearer <your Surplus API key>.x-fal-target-urlstringFal only, and required there. The absolute
httpstarget onfal.runorqueue.fal.run.X-SI-RequirestringComma-separated traits the serving account must claim, e.g.
capacity.dedicated,residency.eu. No offer claims all of them ⇒trait_unavailable.Idempotency-KeystringOptional, up to 255 characters. Being enabled: until it is, the header is ignored and a repeat is a second real generation, billed as one. Once enabled, a key makes one upstream call and one charge for 24 hours (per account, or per paying wallet on x402): the same call again is answered with the first answer and
Idempotency-Replayed: true, and charged nothing. Every call under this path takes it, job submits and embeddings included (a job's polls and result are not deduped). See Idempotency-Key below.
Response headers
x-si-buyer-cost-microintegerWhat you were charged, in microdollars.
x-si-list-cost-microintegerWhat the provider would have billed direct. The difference is your saving.
x-si-adapted-paramsstringThe request fields Surplus set for you. On a chat call that sent no output cap, it names the cap field we added (a 4,096-token cap, or the model's context if that is smaller).
All three are CORS-exposed. A successful call is charged the provider's reported usage or the quote, whichever is lower, and at least 1 µ$ when it cost anything. A call the provider answers with an error is charged nothing, on prepaid credit and on the x402 rail alike.
Two cases are charged the quote, because the provider may still bill the seller for the work: a call the
provider did not answer in time (504 resource_upstream_timeout), and a streamed answer that ends without
usable usage (it broke off, carried no usage, or you stopped reading). Retry a timed-out call only if you accept
a second charge: once Idempotency-Key dedupe is enabled, a retry with the same key is refused
409 idempotency_replay_unavailable and charged nothing, so a second run needs a new key.
curl -X POST $SURPLUS_BASE_URL/resources/elevenlabs/v1/sound-generation \ -H "Authorization: Bearer $SURPLUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text":"a short soft chime","duration_seconds":1}' \ --output chime.mp3
curl -X POST $SURPLUS_BASE_URL/resources/wavespeed/api/v3/wavespeed-ai/flux-schnell \ -H "Authorization: Bearer $SURPLUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"prompt":"a tiny blue paper boat","size":"1024*1024"}'
# EMPTY path — the target is the header. curl -X POST $SURPLUS_BASE_URL/resources/fal \ -H "Authorization: Bearer $SURPLUS_API_KEY" \ -H "Content-Type: application/json" \ -H "x-fal-target-url: https://fal.run/fal-ai/flux/schnell" \ -d '{"prompt":"a tiny red origami crane","image_size":"square"}'
The minimum-discount mirror
Identical, except only offers at least N% off are considered. Nothing that cheap ⇒ no_resource_offer
rather than a worse price. See minimum-discount routing.
The x402 rail
The same proxy, paid per call with an x402 payment proof instead of prepaid credit - no Surplus key needed.
Fal's queue is not available on this rail: a model that must be queued answers job_route_required telling you
to use an API key. GET /.well-known/x402 advertises the rail.
A successful call settles its charge plus the flat fee (flat_fee_micro in GET /x402/info). A call the provider
answers with an error is charged nothing: the payment is never settled. A call the provider did not answer in
time settles its quote plus the flat fee.
Idempotency-Key
This is being enabled. Until it is, Idempotency-Key is ignored on the buyer proxy, and a repeated call is a
second real generation, billed as one.
Once enabled, every call under /v1/resources/{resource}/… (and its /min{N} and x402 forms), job
submits and embeddings included, takes an optional Idempotency-Key. A call that sends one is claimed for 24 hours, per account
(per paying wallet on x402) and key:
| You send | You get |
|---|---|
The same call again (method, path including any /min{N} prefix, query and body) | The first answer, its status, body and x-si-* headers, plus Idempotency-Replayed: true. No upstream call and no charge. The cost headers describe the original charge. A stream comes back as one body with the same bytes. |
| The same key while the first call is still running | 409 idempotency_in_progress. Retry shortly. |
| The same key with a different call | 422 idempotency_key_reused. Nothing is sent or charged. |
| The same key after a call whose answer was not kept | 409 idempotency_replay_unavailable, naming the first request's id. No upstream call and no charge. |
| The same key after a call refused before any charge (no credit, no offer, every seller failed) | The call runs again: the refusal released the key. |
/min{N} prefix, query and body)You get · The first answer, its status, body and x-si-* headers, plus Idempotency-Replayed: true. No upstream call and no charge. The cost headers describe the original charge. A stream comes back as one body with the same bytes.409 idempotency_in_progress. Retry shortly.422 idempotency_key_reused. Nothing is sent or charged.409 idempotency_replay_unavailable, naming the first request's id. No upstream call and no charge.- What is replayed. Whatever the provider answered, an error included: a provider error was charged nothing and
is replayed as the same error. A job submit's answer (the job id and its URLs) is replayed too. Its follow-ups (polls
and the result) are not deduped and work as before.
x-surplus-webhook-secretcomes only with the first answer, so keep it. - What is not kept: the answer to a secret-masked call, a zero-data-retention call (a ZDR key, its
data.zdrscope, orX-SI-Require: data.zdr), an answer over 4 MiB, a stream that ended early, and a timed-out call (504 resource_upstream_timeout, charged its quote). A repeat of these gets409 idempotency_replay_unavailable. - x402. A repeat needs a fresh payment authorization, because the first is single-use. A replay, a 409 or a 422 never settles it.
- The Requests log. A replay writes no entry.
- Other errors. A key over 255 characters is
400 idempotency_key_invalid. If the key cannot be checked, the call is refused503 idempotency_unavailablebefore anything runs; retry. - Storage. Sending the key asks us to keep that one answer, encrypted, for 24-48 hours so it can be replayed. A secret-masked call's or a zero-data-retention call's answer is never kept.
Errors
Every refusal names one cause, so you can tell whose problem it is.
| Code | Status | Meaning |
|---|---|---|
unexpected_path | 400 | A header-style provider was given a path. |
provider_unpriceable | 400 | Cannot be priced, so it is refused rather than guessed. |
job_route_required | 400 | This model can run for minutes - submit it to the provider's queue. |
insufficient_credit | 402 | Add prepaid credit. Nothing was reserved. |
platform_route_refused | 403 | The platform fence. Never reachable, for any seller. |
policy_refused | 403 | Offers exist; no seller's rules allow this call. |
no_resource_offer | 503 | Nobody lists this provider, or none meets your min{N}. |
job_not_found | 404 | Not your job, or its 27-hour binding expired. |
trait_unavailable | 503 | Nobody advertises what you required. |
seller_cap_reached | 503 | Every capable offer spent its cap. Resets 00:00 UTC. |
offers_unhealthy | 503 | Offers exist, but every capable one is paused or backed off right now. |
resource_upstream_failed | 502 | Every seller tried failed upstream; nothing was charged. On api.surplusintelligence.ai the edge may replace this body with a generic error page, so key on the 502 status, and retry. |
resource_upstream_timeout | 504 | The provider did not answer in time and may still be running the call, so it was charged its quote. As with the 502, the edge may answer with a generic error page. |
idempotency_key_invalid | 400 | The Idempotency-Key is longer than 255 characters. |
idempotency_in_progress | 409 | A call with this Idempotency-Key is still running. Retry shortly. |
idempotency_replay_unavailable | 409 | This key already ran and its answer was not kept. Nothing was sent or charged again. |
idempotency_key_reused | 422 | This key was used with a different call. Use a new key. |
idempotency_unavailable | 503 | The key could not be checked, so nothing ran. Retry. |
unexpected_pathStatus · 400Meaning · A header-style provider was given a path.provider_unpriceableStatus · 400Meaning · Cannot be priced, so it is refused rather than guessed.job_route_requiredStatus · 400Meaning · This model can run for minutes - submit it to the provider's queue.insufficient_creditStatus · 402Meaning · Add prepaid credit. Nothing was reserved.platform_route_refusedStatus · 403Meaning · The platform fence. Never reachable, for any seller.policy_refusedStatus · 403Meaning · Offers exist; no seller's rules allow this call.no_resource_offerStatus · 503Meaning · Nobody lists this provider, or none meets your min{N}.job_not_foundStatus · 404Meaning · Not your job, or its 27-hour binding expired.trait_unavailableStatus · 503Meaning · Nobody advertises what you required.seller_cap_reachedStatus · 503Meaning · Every capable offer spent its cap. Resets 00:00 UTC.offers_unhealthyStatus · 503Meaning · Offers exist, but every capable one is paused or backed off right now.resource_upstream_failedStatus · 502Meaning · Every seller tried failed upstream; nothing was charged. On api.surplusintelligence.ai the edge may replace this body with a generic error page, so key on the 502 status, and retry.resource_upstream_timeoutStatus · 504Meaning · The provider did not answer in time and may still be running the call, so it was charged its quote. As with the 502, the edge may answer with a generic error page.idempotency_key_invalidStatus · 400Meaning · The Idempotency-Key is longer than 255 characters.idempotency_in_progressStatus · 409Meaning · A call with this Idempotency-Key is still running. Retry shortly.idempotency_replay_unavailableStatus · 409Meaning · This key already ran and its answer was not kept. Nothing was sent or charged again.idempotency_key_reusedStatus · 422Meaning · This key was used with a different call. Use a new key.idempotency_unavailableStatus · 503Meaning · The key could not be checked, so nothing ran. Retry.Discovery
No authentication - these are the public book.
GET /api/markets/keyspublicEvery Provider Market provider: its id, unit, live and healthy offer counts, the best discount that can serve right now, the capabilities sellers serve, and each live offer in the order the router fills them. Cached 60 seconds.
GET /v1/resource/capabilitiespublicThe capability catalogue a seller scopes a listing with. Cached 5 minutes.
GET /v1/resource/traitspublicWhat a buyer may require with
X-SI-Require, and each trait's provenance. Cached 5 minutes.GET /v1/resource/market/analyticspublicMarket-wide volume and savings.
GET /v1/resource/markets is not the Provider Market list: it covered only the older x402 resource relays,
which were retired on 2026-11-20.
curl https://api.surplusintelligence.ai/api/markets/keys
{
"listings": [
{
"resource_id": "elevenlabs",
"provider": "ElevenLabs",
"unit": "per 1k characters",
"status": "live",
"discount_percent": 50,
"healthy": true,
"active_offers": 3,
"healthy_offers": 3,
"capabilities": ["elevenlabs.speech", "elevenlabs.music"]
}
]
}Buyer reads
These need your Surplus API key.
GET /v1/resource/book/{provider}One provider's book as the router sees it for you: the live offers, their discounts and whether they can serve you. Add
?require=with trait ids to see which offers meet them; an unknown trait id is refused.GET /v1/resource/accessWhether your account may buy on the Provider Market right now, and why not if it may not.
GET /v1/resource/buyer/analyticsYour spend and savings on provider keys.
Seller endpoints
All under /v1/resource/seller, all requiring a seller-authenticated key.
POST /v1/resource/seller/keys/probefreeValidate a provider key before listing it. Body
{ resource_id, api_key }. The key is used once and never stored. A bad key answers200withok: false.POST /v1/resource/seller/offersList a key.
resource_typeandapi_keyare required,discount_percentis a whole number 5–80, and bothack_persists_stateandack_provider_termsmust betrue.GET /v1/resource/seller/offersYour listings. Never includes the key or any fragment of it.
PATCH /v1/resource/seller/offers/{id}Reprice, re-cap, re-scope or pause.
DELETE /v1/resource/seller/offers/{id}Delist, releasing the uniqueness claim.
POST /v1/resource/seller/offers/{id}/purgeDelist and destroy the stored credential.
DELETE /v1/resource/seller/offersDelist everything.
GET /v1/resource/seller/analyticsEarnings, and the demand your own rules refused.
A credential may back one active offer per model, per base URL, across every workspace and
organization. A second is refused 409 duplicate_offer_for_credential.
Key listings take api_key only (api_secret ⇒ api_secret_unsupported) and are priced by
discount_percent only (pricing_multiplier ⇒ pricing_multiplier_unsupported).
curl -X POST $SURPLUS_BASE_URL/resource/seller/keys/probe \ -H "Authorization: Bearer $SURPLUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"resource_id":"elevenlabs","api_key":"<provider key>"}'
curl -X POST $SURPLUS_BASE_URL/resource/seller/offers \ -H "Authorization: Bearer $SURPLUS_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "resource_type": "elevenlabs", "api_key": "<provider key>", "label": "Spare ElevenLabs capacity", "discount_percent": 50, "cap_daily_usd": 25, "ack_persists_state": true, "ack_provider_terms": true }'
{
"id": "roff_01JC…",
"resource_type": "elevenlabs",
"discount_percent": 50,
"active": true
}Related
- Your first call - the end-to-end buyer path.
- Jobs and settlement - async jobs and when money moves.
- Access rules - why a call is or is not reachable.
- Listing your key - the seller path.