Overview

API reference

Base URL, headers, conventions and every endpoint.

The Astorie API is a JSON HTTP API. These pages list every endpoint with its fields. For the ideas behind them, start with How the API works.

Base URL

Base URL
https://astorie.ai/api/gateway/v1

Authentication

Send your key as a bearer token on every request. See Authentication.

Header
Authorization: Bearer ast_gw_...

Endpoints

EndpointScope
GET /v1/modelsmodels:readList models
GET /v1/capabilitiesmodels:readGet model capabilities
POST /v1/quotesquotes:createCreate a quote
GET /v1/quotes/{id}quotes:readGet a quote
POST /v1/jobsjobs:createCreate a job
GET /v1/jobsjobs:readList jobs
GET /v1/jobs/{id}jobs:readGet a job
POST /v1/jobs/{id}/canceljobs:cancelCancel a job
POST /v1/filesfiles:writeCreate a file
GET /v1/balancewallet:readGet balance
GET /v1/ledgerwallet:readList ledger entries

Headers

HeaderDirectionMeaning
AuthorizationRequestYour API key, as Bearer ast_gw_....
Content-TypeRequestapplication/json on every POST with a body.
Idempotency-KeyRequestRequired on POST /v1/jobs and POST /v1/files.
X-Request-IdResponseUnique per request. Quote it to support.
X-Idempotent-ReplayResponsetrue when the response came from an earlier request with the same key.
Retry-AfterResponseSeconds to wait before retrying a 429 or 503.

Conventions

  • Fields are snake_case. Responses carry api_version: "v1" and an object type.
  • Money is a decimal string with six places, such as "0.080000". Never send a number. The exception is the display prices in GET /v1/models, which drop trailing zeros.
  • Times are RFC 3339 in UTC.
  • A resource that doesn't exist and one that belongs to another account both return 404 not_found.
  • New fields and enum values can be added without notice. Ignore ones you don't know.

Pagination

List endpoints take limit (1 to 100) and return data, has_more and next_cursor. Pass next_cursor back as cursor for the next page. The ledger pages by sequence number instead. See List ledger entries.

Errors

Errors return an HTTP status and a body with error.code, error.message, error.retryable, error.details and request_id. The full list is on Errors.