aiml docs
Migrate

From OpenRouter

Same model naming, same OpenAI-compatible route, different headers and billing.

OpenRouter users have the shortest path: model ids are already vendor/model and the route is already /v1/chat/completions.

The changes

  1. Base URL https://openrouter.ai/api/v1 becomes https://api.ai.ml/v1.
  2. Key sk-or-… becomes aiml-live-….
  3. Headers HTTP-Referer and X-Title are not needed. Put the app name in aiml.metadata.app if you want it in analytics.
cookbook/python/streaming.py#L5-L7
from openai import OpenAI

client = OpenAI(base_url=os.environ.get("AIML_BASE_URL", "https://api.ai.ml") + "/v1", api_key=os.environ["AIML_API_KEY"])

Mapping OpenRouter features

OpenRouteraiml
provider: { order: [...], allow_fallbacks }aiml.route.providers.order and aiml.route.fallbacks
provider: { only: [...], ignore: [...] }aiml.route.providers.only, aiml.route.providers.ignore
provider: { data_collection: "deny" }aiml.route.require.zdr: true (or data_policy: "no_train")
provider: { sort: "price" }aiml.route.sort
provider: { max_price }aiml.route.require.max_price
models: [...] (model fallbacks)one model per request; aiml.route.fallbacks moves between endpoints of that model
transforms: ["middle-out"]not offered; the gateway returns context_length_exceeded rather than silently truncating
GET /api/v1/generation?id=GET /v1/generation/{id} (the id is x-aiml-request-id)
GET /api/v1/modelsGET /v1/models; per-model endpoints at GET /v1/models/{vendor}/{model}/endpoints
x-openrouter-* headersx-aiml-* headers, see curl quick start

Billing differences

  • Prices are shown per million tokens in the catalog and billed as integer nano-USD per token; each usage line is rounded once. aiml.cost.lines in the response breaks the total down.
  • The balance is reserved before the call from your estimate and settled from the provider's usage; you never see a charge larger than the settled cost.
  • Top-ups are in your billing currency (INR via Razorpay with GST invoices, otherwise USD via Stripe); credits are always USD. See Billing.

On this page