aiml docs
ReferenceAPI reference

Native

the IR surface (M2): generate, embed, rerank, count_tokens, dry_run

POST/v1/aiml/embed
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/v1/aiml/embed" \  -H "Content-Type: application/json" \  -d '{    "model": "voyage/voyage-3",    "input": [      "what does the ledger do?"    ],    "input_type": "query"  }'
{  "object": "list",  "id": "01J8REQ000000000000000AB01",  "model": "voyage/voyage-3",  "data": [    {      "index": 0,      "embedding": [        0.0123,        -0.0456      ],      "dimensions": 1024    }  ],  "usage": {    "input_tokens": 7,    "total_tokens": 7,    "source": "provider"  },  "resolved": {    "provider": "voyage",    "endpoint_id": "ep_voyage_voyage-3_us"  },  "cost": {    "total_micro_usd": 1  }}
POST/v1/aiml/rerank
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/v1/aiml/rerank" \  -H "Content-Type: application/json" \  -d '{    "model": "cohere/rerank-3.5",    "query": "how do credits expire?",    "documents": [      "grants expire after 14 days",      "the gateway streams tokens"    ],    "top_n": 1,    "return_documents": true  }'
{  "object": "rerank",  "id": "01J8REQ000000000000000AB02",  "model": "cohere/rerank-3.5",  "results": [    {      "index": 0,      "relevance_score": 0.91,      "document": "grants expire after 14 days"    }  ],  "usage": {    "input_tokens": 18,    "search_units": 1,    "source": "provider"  },  "cost": {    "total_micro_usd": 9  }}
POST/v1/aiml/generate
AuthorizationBearer <token>

In: header

Header Parameters

aiml-version?string

API version (YYYY-MM-DD); defaults to the key's pinned version

Formatdate
Idempotency-Key?string

replay-safe retries of billed calls (part2a §7.1)

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

ai.ml canonical generate request (docs/plan part2a §6.2). aiml-version 2026-09-09.

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/v1/aiml/generate" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-5-mini",    "messages": [      {        "role": "user",        "content": [          {            "type": "text",            "text": "Summarise the attached invoice in one line."          }        ]      }    ],    "generation": {      "max_tokens": 256,      "temperature": 0.2    },    "route": {      "sort": "price",      "fallbacks": true    },    "metadata": {      "app": "chatbot",      "user_id": "u_42"    }  }'
{  "id": "01J9ZK2K4Q7Q3M3QX1V0F1GATE",  "model": "openai/gpt-5-mini",  "candidates": [    {      "index": 0,      "content": [        {          "type": "text",          "text": "Invoice AIML/26-27/000001: ₹1,180.00 for prepaid credits, GST included."        }      ],      "stop": {        "reason": "end_turn"      }    }  ],  "usage": {    "input_tokens": 812,    "output_tokens": 143,    "cache_read_tokens": 0,    "cache_write_tokens": 0,    "reasoning_tokens": 0  },  "cost": {    "total_micro_usd": 489,    "lines": [      {        "kind": "input",        "units": 812,        "unit_price_nano": 250,        "micro_usd": 203      },      {        "kind": "output",        "units": 143,        "unit_price_nano": 2000,        "micro_usd": 286      }    ],    "price_version": "pv_01J9ZK2K4Q7Q3M3QX1V0F1PV01"  },  "provider_meta": {    "provider": "openai",    "endpoint_id": "ep_openai_gpt-5-mini_us"  },  "warnings": []}
POST/v1/aiml/count_tokens
AuthorizationBearer <token>

In: header

Header Parameters

aiml-version?string

API version (YYYY-MM-DD); defaults to the key's pinned version

Formatdate

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

ai.ml canonical generate request (docs/plan part2a §6.2). aiml-version 2026-09-09.

Response Body

application/json

application/json

curl -X POST "https://example.com/v1/aiml/count_tokens" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-5-mini",    "messages": [      {        "role": "user",        "content": [          {            "type": "text",            "text": "hi"          }        ]      }    ]  }'
{  "input_tokens": 812,  "source": "exact",  "tokenizer": "o200k_base"}
POST/v1/aiml/dry_run
AuthorizationBearer <token>

In: header

Header Parameters

aiml-version?string

API version (YYYY-MM-DD); defaults to the key's pinned version

Formatdate

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

ai.ml canonical generate request (docs/plan part2a §6.2). aiml-version 2026-09-09.

Response Body

application/json

application/json

application/json

curl -X POST "https://example.com/v1/aiml/dry_run" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-5-mini",    "messages": [      {        "role": "user",        "content": [          {            "type": "text",            "text": "Summarise the attached invoice in one line."          }        ]      }    ],    "generation": {      "max_tokens": 256,      "temperature": 0.2    },    "route": {      "sort": "price",      "fallbacks": true    },    "metadata": {      "app": "chatbot",      "user_id": "u_42"    }  }'
{  "plan": [    {      "endpoint_id": "ep_openai_gpt-5-mini_us",      "provider": "openai",      "score": 0.97    }  ],  "warnings": [],  "reserve_micro": 2600,  "price_version": "pv_01J9ZK2K4Q7Q3M3QX1V0F1PV01"}