SandBase Tasks API
Asynchronous model task status, settlement, and usage
Asynchronous model task status, settlement, and usage
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/sandbase-ai:sandbase-ai-tasks-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: SandBase Tasks API
description: 'SandBase is an agent-native platform for connecting Agents to the real world.
Use one account and one key to call Models, ready-made APIs, and Agents.
## Authentication
Public API requests require a SandBase API key. Use `Authorization: Bearer sk-YOUR_KEY` by default.
Anthropic Messages and Google Gemini-compatible operations also document their native SDK-compatible key locations.
## SDK Compatibility
- **LLM Gateway** (`/v1/chat/completions`): Use OpenAI SDK with `base_url="https://api.sandbase.ai/v1"`
- **Embeddings** (`/v1/embeddings`): Use OpenAI SDK with `base_url="https://api.sandbase.ai/v1"`
- **Images** (`/v1/images/generations`, `/v1/images/edits`): Use OpenAI SDK with `base_url="https://api.sandbase.ai/v1"`
- **Anthropic Messages** (`/v1/messages`): Use Anthropic SDK with `base_url="https://api.sandbase.ai"`
- **Google Gemini GenerateContent** (`/v1beta/models/{model}:generateContent`): Configure the Google Gen AI SDK to use `https://api.sandbase.ai`
- **Agents and Sessions** (`/v1/agents`, `/v1/agents/sessions`): Follow the OpenAI Agents protocol (`OpenAI-Beta: agents=v1` is optional) plus the documented SandBase extensions
- **Agents platform resources** (`/v1/agents*`, `/v1/mcp-connections*`, `/v1/secrets*`, `/v1/skills*`): Accept `Authorization: Bearer` or `X-API-Key` and return the `AgentsError` envelope'
version: 1.0.0
x-sandbase-session-contract:
status: active
feature: Agents platform Sessions
description: A Session (ses_*) runs one saved Agent version in a SandBase-hosted environment. Sessions are created directly with POST /v1/agents/sessions. Internal runtime identities are never exposed.
contact:
name: SandBase
url: https://www.sandbase.ai
license:
name: Proprietary
servers:
- url: https://api.sandbase.ai
description: Production
security:
- BearerAuth: []
tags:
- name: Tasks
description: Asynchronous model task status, settlement, and usage
paths:
/v1/tasks/{task_id}/cost:
get:
operationId: getTaskCost
tags:
- Tasks
summary: Get task cost and usage
description: 'Returns the settlement status, final user cost, estimated cost, and token usage for a recent task.
Public API keys can retrieve only tasks originally created by that same API key, even when another key belongs to the same organization.
This lookup remains available after the key reaches its spending limit, but expired, revoked, or scoped keys are still rejected.
When `settled` is false, `cost` is not final and must not be used for billing or reconciliation.
Use `estimated_cost` only as a display estimate until final settlement completes.
Older task execution records may be archived after the retention window and then return 404.
Use billing records or billing exports for long-term reconciliation.'
parameters:
- name: task_id
in: path
required: true
description: Opaque task ID returned by a billable operation, including an x-task-id response header when present.
schema:
type: string
responses:
'200':
description: Task cost and usage
content:
application/json:
schema:
$ref: '#/components/schemas/TaskCostResponse'
'401':
description: Missing or invalid API key
content:
application/json:
schema:
$ref: '#/components/schemas/TaskCostError'
'403':
description: API key scope does not authorize this endpoint
content:
application/json:
schema:
$ref: '#/components/schemas/APIKeyScopeError'
'404':
description: Task does not exist or is not accessible with the current API key
content:
application/json:
schema:
$ref: '#/components/schemas/TaskCostError'
components:
schemas:
TaskCostResponse:
type: object
required:
- id
- status
- settled
- currency
- cost
- estimated_cost
- usage
properties:
id:
type: string
description: SandBase task ID.
status:
type: string
enum:
- pending
- running
- completed
- failed
- timeout
settled:
type: boolean
description: Whether final cost settlement has completed.
currency:
type: string
enum:
- USD
cost:
type: string
pattern: ^\d+\.\d{6}$
description: USD amount with six decimal places. Not final while settled is false.
example: '0.001234'
estimated_cost:
type: string
pattern: ^\d+\.\d{6}$
description: Best-effort USD estimate with six decimal places. Informational while settled is false; matches cost once settled is true.
example: '0.001234'
usage:
$ref: '#/components/schemas/TaskCostUsage'
pricing:
$ref: '#/components/schemas/TaskCostPricing'
APIKeyScopeError:
type: object
required:
- error
properties:
error:
type: object
required:
- code
- message
- request_id
properties:
code:
type: string
const: insufficient_scope
message:
type: string
request_id:
type: string
TaskCostPricing:
type: object
description: Present only after settlement when a discount breakdown was recorded. original_cost minus discount_amount equals cost.
required:
- original_cost
- discount_amount
- discount_percent
properties:
original_cost:
type: string
pattern: ^\d+\.\d{6}$
description: USD cost before discounts, with six decimal places.
discount_amount:
type: string
pattern: ^\d+\.\d{6}$
description: USD discount applied, with six decimal places.
discount_percent:
type: number
minimum: 0
description: Discount percentage, for example 25 for 25 percent off.
discount_type:
type: string
description: Kind of discount applied. Omitted when not recorded.
TaskCostUsage:
type: object
required:
- prompt_tokens
- completion_tokens
- total_tokens
- cached_tokens
- cache_creation_tokens
- reasoning_tokens
properties:
prompt_tokens:
type: integer
minimum: 0
completion_tokens:
type: integer
minimum: 0
total_tokens:
type: integer
minimum: 0
cached_tokens:
type: integer
minimum: 0
cache_creation_tokens:
type: integer
minimum: 0
reasoning_tokens:
type: integer
minimum: 0
TaskCostError:
type: object
required:
- error
properties:
error:
type: string
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: SandBase API key. Treat the complete credential as an opaque secret.
AnthropicApiKey:
type: apiKey
in: header
name: x-api-key
description: Supported only by `POST /v1/messages` for Anthropic SDK compatibility
GoogleApiKey:
type: apiKey
in: header
name: x-goog-api-key
description: Supported by Google Gemini-compatible endpoints. Takes precedence over the other key locations.
GoogleQueryApiKey:
type: apiKey
in: query
name: key
description: Google SDK compatibility fallback. Prefer x-goog-api-key or Authorization because URLs can be logged.
WebhookApiKey:
type: apiKey
in: header
name: X-API-Key
description: Accepted by the webhook Events API (/events/webhooks*). Authorization Bearer takes precedence when both are sent.
AgentsApiKey:
type: apiKey
in: header
name: X-API-Key
description: Accepted only by Agents platform resources (/v1/agents*, /v1/mcp-connections*, /v1/secrets*, /v1/skills*). If Authorization is also sent, both must carry the same key.