REST API

Direct HTTP access to inference shell.


Base URL

code
1https://api.inference.sh

Path prefix

There is none. Routes live at the root of the API host:

bash
1curl https://api.inference.sh/tasks/task_abc123 -H "Authorization: Bearer inf_your_key"

Authentication

All requests require an API key in the Authorization header:

code
1Authorization: Bearer inf_your_api_key

Content Type

code
1Content-Type: application/json

Response format

Every JSON response is an envelope: the resource under data, and messages for any notices the server attached (level, code, message, optional meta). Errors are RFC 9457 application/problem+json. Streams (SSE, NDJSON) carry bare DTOs per event. The official SDKs unwrap data and surface messages through a callback.

Success example (task from POST /run):

json
1{2  "data": {3    "id": "task_abc123",4    "status": 10,5    "output": { "image": { "uri": "https://..." } }6  },7  "messages": []8}

Error example (401):

json
1{2  "type": "https://api.inference.sh/errors/unauthorized",3  "title": "Unauthorized",4  "status": 401,5  "detail": "Invalid or missing API key"6}

Older examples on other pages show the resource without the data wrapper; read it from data.

bash
1curl https://api.inference.sh/tasks/task_abc123 \2  -H "Authorization: Bearer inf_your_key"

Error Responses

Errors use Content-Type: application/problem+json with the type, title, status, and detail fields shown above. The type URI ends with the error code (for example .../errors/not_found).

Some errors include an optional meta extension member with structured context — for example entitlement errors (limit_exceeded, feature_not_available) attach resource, limit, current, upgrade_available, and optional addon plan fields (see Entitlements API — Error metadata); in_other_workspace attaches team_id.

Error Codes

CodeHTTPDescription
unauthorized401Invalid or missing API key
forbidden403Insufficient permissions
in_other_workspace403The resource lives in another workspace you belong to. meta.team_id names it. See Resources in another of your workspaces.
blocked_by_usage_policy403Resource is outside the workspace usage policy reach (apps, agents, MCPs, knowledge, flows). Checked before prepaid balance on paid runs — not a credits problem.
not_found404Resource not found
listing_not_live410The resource's store listing serves no reviewed version now. See Store live version
invalid_request400Malformed request
visibility_not_allowed400The resource cannot take that visibility. See Allowed visibility per resource
rate_limited429Too many requests
requirements_not_met412Missing secrets, credentials or OAuth scopes. The problem carries an errors array (repeated under meta.errors) with the objects POST /credentials/check returns. POST /run and POST /apps/run answer 412 with plain JSON {"satisfied": false, "errors": [...]} instead
entitlement_unavailable500The entitlement lookup failed, so plan limits could not be verified. Retriable.
internal_error500Server error
maintenance503The platform is in maintenance and does not start new work. See Platform maintenance.

Platform maintenance

During planned maintenance the platform stops starting new work. Requests that would start work (runs, chat messages, flow runs, deploys, sandbox and engine starts, MCP calls, webhooks that start runs) answer 503 maintenance. Reads, cancels and work already running go on as usual. Queued tasks that are not part of a running chat or flow wait until maintenance ends.

The refusal has a Retry-After header in seconds, and meta.retry_after (the same number) and meta.until (expected end, when set). With no expected end, Retry-After is 5 minutes. detail is the maintenance message.

GET /maintenance needs no auth and returns the current state under data:

json
1{2  "mode": "draining",3  "message": "inference.sh is under maintenance. New runs are paused; work already running finishes. Try again shortly.",4  "until": "2026-11-04T12:00:00Z"5}

mode is off or draining. message and until are left out when not set. This is not the same as app_maintenance, which one app's owner sets for that app only (see Tasks API errors).

Resources in another of your workspaces

A read refused in the workspace you act in normally answers 404 not_found. When you belong to the workspace that owns the resource and could open it while acting there (it is not another member's private row), the answer is 403 in_other_workspace instead, with that workspace in meta.team_id:

json
1{2  "type": "https://api.inference.sh/errors/in_other_workspace",3  "title": "Forbidden",4  "status": 403,5  "detail": "this lives in another of your workspaces",6  "meta": { "team_id": "team_abc123" }7}

Send the request again with X-Team-ID set to meta.team_id. A resource in a workspace you are not in, or another member's private row, still answers 404. The code is the last segment of type; the body has no top-level code field.

Pre-authentication access controls

Some requests are rejected before authentication. These responses do not use the problem+json format above:

ConditionHTTPResponse
IP blocked for abuse403{ "message": "Access denied. This attempt has been logged. If you believe this is a mistake, please disconnect any VPN or proxy and try again, or contact security@inference.sh." }
Region blocked (sanctions)451service not available in your region (plain text)

Both checks apply to almost every route. Some health and status endpoints stay reachable. They are separate from the permission 403 errors (forbidden, feature_not_available) returned after authentication.

Regional blocking uses the request's country and, for some countries, its subdivision. Blocked countries are Cuba, Iran, North Korea, Russia, and Syria. Within Ukraine, Crimea, Sevastopol, Donetsk, and Luhansk are blocked. VPN or proxy exit nodes in a blocked region get the same response.

CORS (browser clients)

Browser fetch from JavaScript needs CORS headers on the response. The API answers in two modes, chosen from the request's Origin header:

OriginAccess-Control-Allow-OriginCredentials
The deployment's own app (for example https://app.inference.sh) and any extra hosts configured for that deploymentThe matching originAllowed (Access-Control-Allow-Credentials: true)
Any other origin, whatever the request's auth*Not allowed: cookies are never honoured cross-site, so send an API key in Authorization

Both modes allow methods GET, POST, PUT, DELETE, OPTIONS, and HEAD, request headers Accept, Authorization, Content-Type, X-CSRF-Token, X-Team-ID, X-Client-Source, and X-API-Version, and expose the response headers Link and Retry-After (see Rate limits below).

A write (POST, PUT, PATCH, DELETE) that carries the session cookie from an origin outside the first row is refused with 403 cross_origin_write (this request must come from the inference.sh app).

Refusals stay readable. CORS runs before middleware that can end the request early: invalid or revoked bearer tokens, suspended accounts, denied impersonation, regional blocks, and IP redlist hits. Those answers carry CORS headers for every origin, so browser code sees the real HTTP status and body instead of an opaque network error.

Signup email restrictions

New accounts cannot use temporary or disposable email domains. The check runs when a new user record would be created, so every sign-up path enforces it:

Auth pathWhen the check runsError for new signups
Magic link (POST /auth/magic-link/send)Before the email is sentdisposable_email (400)
OAuth sign-inAfter the provider redirects backdisposable_email (400)
SAML SSOOn first login for a new emailuser_creation_failed (500). Use a permanent address and retry.

Existing accounts are not affected. An account registered on such a domain before the restriction can still sign in.

Stored form: Email addresses on user accounts and pending team invites are stored trimmed and lowercased. Sign-in and account lookup match case-insensitively, so You@Example.com and you@example.com resolve to the same account when only one exists. API responses return the stored address.

For Gmail and Googlemail, team invites and membership checks also treat addresses that deliver to the same mailbox as one address (dots in the local part and + tags after the local part are ignored for that comparison). Magic link sign-in uses the same mailbox rules when plus-alias blocking is enabled.

Plus addressing (+ aliases) on magic link: New sign-ups can currently use + in the local part (for example you+tag@example.com). The API may enable stricter checks later to block aliases that would open a separate account (trial-credit abuse). When that enforcement is on, POST /auth/magic-link/send returns invalid_email (400) for a new address whose provider treats + as a distinct mailbox. Gmail and Googlemail are always allowed: those providers fold + tags into one mailbox, and sign-in lands on the canonical account. An address that already has an account is never blocked by the alias rule. OAuth and SAML do not apply the magic-link alias rule.


Billing and plan limits

These billing and plan errors can block API calls:

KindTypical codesWhat to check
Plan limitslimit_exceeded (402), feature_not_available (403)Subscription tier caps — API keys, storage, concurrent tasks, feature flags
Entitlement lookup failureentitlement_unavailable (500)Transient server error while reading plan limits. Retry. Not a tier cap.
Usage policyblocked_by_usage_policy (403)Outside-resource reach and allow/block lists — see Usage policy. On paid runs the API judges policy before balance, so a blocked app never returns payment_required.
Prepaid balancepayment_required (402)Credits for task and agent runs the usage policy already allows
Payment methodpayment_method_required (402)A run certain to cost $0 needs a saved payment method when the balance would refuse it; meta.billing_page names the page that adds one. See Billing: free runs.

Inspect current usage programmatically with GET /entitlements/usage. List entitlement rows (limits and sources) with GET /entitlements. See Entitlements API for response formats and error metadata.

Web app modals

In the inference shell app, entitlement errors with upgrade_available: true open an upgrade modal instead of only surfacing a toast:

API errorModal
limit_exceeded or feature_not_available (tier cap)Upgrade modal — lists self-serve plans above your current tier
feature_not_available with addon_plan_idAdd-on purchase modal — shows addon name, price, and subscribe - $X/mo CTA that routes to the add-ons page
payment_required (402 without upgrade_available)Top-up modal — add prepaid credits

For payment_required, credits always go to whoever pays for the selected workspace (the team itself, or the organization workspace for an org member team). If you manage organization billing while switched into a member team, checkout runs against the organization balance and returns to that workspace's billing settings. If the organization pays and you cannot manage its billing, the modal shows the org notice instead of checkout — the same rule as inline add credits controls elsewhere in the app.

The upgrade modal shows the API detail message (or which resource requires a higher plan). For limit_exceeded, it also shows current usage / plan cap (for example 3 / 5) when the cap is greater than zero. A 0 cap means the feature is disabled on your tier — the modal omits a usage line instead of showing 0 / 0.

Each listed plan shows monthly price, included credits, and key limits. The recommended badge marks the cheapest plan that resolves the blocked resource (unlimited, a higher numeric cap, or an enabled boolean feature). Select a plan or View all plans to open settings → workspace → subscription.

When the error includes addon_plan_id, the modal shows a single add-on card with a subscribe - $X/mo button that routes to settings → workspace → add-ons, the same purchase flow as the add-ons page (Stripe Checkout via POST /subscription/addon). Most add-ons do not require a base subscription; some set required_plan_ids on the plan.

Direct links: Pricing (browse plans) · settings → workspace → billing (credits) · settings → workspace → subscription (manage plan) · settings → workspace → add-ons (purchase add-ons)


Description length limits

Create and update endpoints enforce a maximum length on resource description fields. Limits count Unicode characters (runes), not bytes.

ConstantMax lengthApplies to
DescriptionLimitListing200Apps, agent template versions, flows, workspace MCP servers, and knowledge entries whose type is not skill
DescriptionLimitSkill1024Skills (type: skill on knowledge, and skill create/update APIs) — matches the Agent Skills frontmatter limit

When a new description exceeds the limit, the API returns validation_error (400) with detail such as description must be at most N characters, got M. If an update leaves the description unchanged, the limit is not re-checked — existing text longer than the cap can stay until you edit the field.

Agent-facing reads: Discovery and catalog surfaces clip descriptions to 200 characters for the model: whitespace collapses to a single space and overflow ends with .... This includes /suggest result lines and catalog tools such as search_tools / list_tools. Put longer guidance in the resource body (app README, skill instructions, knowledge content, system prompt).

Client-side validation: JavaScript (@inferencesh/sdk ≥ v0.20.0) exports DescriptionLimitListing and DescriptionLimitSkill; Python (inferencesh ≥ v0.19.0) exports DescriptionLimit.LISTING and DescriptionLimit.SKILL on the DescriptionLimit enum in inferencesh.types.

Web app: On app.inference.sh, description fields for apps, agents, flows, skills, workspace MCP servers, and knowledge entries show a counter (n/limit) under the input and stop accepting characters at the same limits as the API. Knowledge uses the skill limit when type is skill or unset, and the listing limit for other types (same rule as knowledge create/update). Text saved before limits existed may still be longer than the cap; the counter turns red until you shorten it, and you can save other fields without editing the description.


Writable fields

A create or update applies only the fields that route writes. Ids, relations (user, team, …), server timestamps and fields with their own route (visibility, moves, shares) are not applied from the body. Send only the fields you mean to change instead of sending back a whole GET response.

  • On update (POST/PUT /<resource>/{id}) and PATCH, a field you leave out keeps its stored value.
  • A field you may not write passes when its value equals the stored one (the zero value on create), so a body copied from a read is not refused for that alone. A relation passes only as null, {} or [].
  • When the API refuses a body, it answers 400 validation_error with meta.fields: one {field, reason} per field, reason one of unknown, relation, read_only, create_only, staff_only.

Rate Limits

EndpointLimit
Run task100/minute
Get task1000/minute
Upload file50/minute

Response headers:

code
1X-RateLimit-Remaining: 952X-RateLimit-Reset: 16400000003Retry-After: 60

Some endpoints (for example magic link send when throttled by IP) return HTTP 429 with a Retry-After header (whole seconds). Browser clients can read it — the API exposes Retry-After in CORS Access-Control-Expose-Headers.


OpenAPI

Download the generated route catalog:

code
1GET https://api.inference.sh/openapi.json

OpenAPI 3.1 document listing public paths, methods, and schemas. Useful for client generation and discovering routes not yet covered in these guides. No authentication required.


Cursor pagination

Most list endpoints (GET /tasks, GET /skills, POST /apps/list, GET /chats/:id/messages, and others) use the same cursor-list shape. Send parameters as query strings on GET or in a JSON body on POST …/list.

FieldTypeDescription
limitintegerPage size, at most 200. Omitted, 0 or negative means the endpoint's default (10, or 50 for chat messages); above 200 means 200.
cursorstringOpaque cursor from next_cursor or prev_cursor
directionstringnext (default) or prev: which way to read from cursor
sortarraySort orders, for example [{ "field": "created_at", "dir": "desc" }]
filtersarrayFilter expressions (field, operator, value)
searchobjectFull-text search (term, fields, …) where supported
fieldsarrayColumns to return on each row. It can only narrow the resource's default list columns: names outside them are ignored, not an error. On GET, a JSON array or a comma-separated list in the query; on POST …/list, a JSON array in the body. Omitted or empty returns every default list column.
preload / preloadsarrayRelated records to embed on each row, where the endpoint supports it. On GET the query parameter is preload (JSON array or comma-separated list); on POST …/list the body key is preloads (JSON array).
include_othersbooleanInclude other users' items in the response, where the endpoint supports it
include_privatebooleanWorkspace owners and admins only. Include every row the selected workspace owns, including members' private resources. Ignored for other roles. Each use is audited. See Workspace admin visibility.

Lists of pin-able resources (chats, agents, apps, projects, flows, knowledge) also take a pinned filter: see Pinned resources.

Workspace admin visibility

By default, list endpoints hide a member's private resources from everyone except the creator. Workspace owners and admins can widen a listing by passing include_private: true (include_private=true in the query string on GET, a JSON body field on POST …/list).

When set, the response includes every row owned by the workspace in the request context: your own private items, other members' private items, and team-visible items. The flag has no effect for the member role, which always gets the standard listing.

Use this when cleaning up a workspace after someone leaves, for example to transfer or delete their private apps, flows, or knowledge. Each include_private list request is audited as team_admin.list_private.

Workspace owners and admins can also read or write an individual member's private resource when the normal permission check would deny access, for example GET /apps/{id} on a departed member's private app. The bypass does not cover running the resource. Each access is audited as team_admin.permission_bypass. Org admins get the same bypass for resources in workspaces attached to their org. Person-owned identity data (exports, sessions, and similar) is never reachable this way.

Response shape

FieldTypeDescription
itemsarrayResources for this page
next_cursorstringCursor for the next page
prev_cursorstringCursor for the previous page
has_nextbooleanMore results after this page
has_previousbooleanResults before this page
items_per_pagenumberItems in this response

Responses may include RFC 8288 Link headers (rel="next", rel="prev") with the same cursors.

Reading every page

There is no single-response dump and no page numbers. To read every matching item, request pages until has_next is false, passing each response's next_cursor as the next request's cursor:

bash
1cursor=""2while :; do3  page=$(curl -s "https://api.inference.sh/tasks?limit=200&cursor=$cursor" \4    -H "Authorization: Bearer inf_your_key")5  echo "$page" | jq -c '.data.items[]'6  [ "$(echo "$page" | jq -r '.data.has_next')" = "true" ] || break7  cursor=$(echo "$page" | jq -r '.data.next_cursor')8done

Visibility and sharing

Who may use a resource follows one rule: you may use it if you own it, or an entry gives you access, and no usage policy forbids it. Owning means you created it, or it belongs to your workspace and is not private. An entry is either a share or the resource's visibility, which works like an entry to the workspace, the organization, or everyone.

Every app, flow, agent, artifact, knowledge entry (skills included) and remote has a visibility:

visibilityWho can read it
privateIts creator. Workspace owners and admins reach it only through the audited admin bypass.
teamEvery member of the owning workspace
orgEvery member of every workspace in the owning workspace's organization
unlistedAnyone with its id or link. Listed and searched only inside the owning workspace.
publicAnyone, signed in or not

Visibility grants read; org also lets members interact, for example write an artifact's page data. Visibility never grants write.

Allowed visibility per resource

Tasks, flow runs and engines stay with their workspace: they take only private and team. Setting any other value returns 400 visibility_not_allowed, with meta.resource, meta.visibility and meta.allowed. A row stored with a wider value before this rule reads as team. These resources are never readable signed out.

Shares

A share gives one person, one workspace, or the whole organization a permission on one resource. Apps, flows, agents, artifacts, knowledge and remotes can be shared. Skills are knowledge entries: share them through /knowledge/{id}.

GranteeWho it reaches
A person (user_id)That person, while they act in the resource's workspace or another workspace of its organization
The resource's workspace (team: true)Every member of it
Another workspace (team_id)Every member of that workspace. It must be in the same organization.
The organization (org: true)Every member of every workspace in the resource's organization

A share never reaches outside the organization. A workspace that is in no organization shares only inside itself.

permissionWhat it allows
read (default)View it, run it (an app, flow or agent), open its content (a skill or knowledge entry), and interact with it (for example comment on an artifact or write its page data)
useThe same as read. On a remote it also allows operating it: commands, harness sessions, placing agents.
writeEverything above, plus change it and manage its shares

Share routes

{resource} is apps, flows, agents, artifacts, knowledge or remotes.

MethodPathDescription
GET/{resource}/{id}/sharesList shares
POST/{resource}/{id}/shareAdd or change a share
DELETE/{resource}/{id}/share/{userId}Remove a person's share
DELETE/{resource}/{id}/team-shareRemove a workspace's share: ?team_id=, the resource's own workspace when absent
DELETE/{resource}/{id}/org-shareRemove the organization's share

Every share route needs the resource's write scope (apps:write, flows:write, agents:write, artifacts:write, knowledge:write, remotes:write) and write access on the resource. A caller who can read the resource but not write it gets 403. A caller who cannot read it gets 404.

POST /{resource}/{id}/share names exactly one grantee and a permission. Sharing again with the same grantee changes its permission.

json
1{2  "team_id": "team_xyz789",3  "permission": "use"4}
Body fieldGrantee
user_idOne person
team: trueThe resource's own workspace
team_idAnother workspace in the same organization
org: trueThe resource's organization

A workspace outside the organization, or an organization share from a workspace in no organization, is refused with 400 validation_error.

Each item from GET /{resource}/{id}/shares carries grantee_type (user, team or org), grantee_id, permission, and the grantee again as user_id, team_id or org_id. Person shares include user.

To list the workspaces a share can name, use GET /orgs/{id}/teams/directory.


Endpoints

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.