# kinl.dev > kinl.dev is an OpenAI-compatible inference API. One base URL, one bearer key, > one prepaid balance, and a request log you can audit. It serves chat, image, > video, music, speech, transcription and embedding models through a single > endpoint shape, so a client that already speaks the OpenAI API only has to > change `base_url` and the key. This file is written for an AI coding agent that has to wire kinl.dev into a project without a human reading documentation first. It is deliberately flat: every fact you need to make the integration work is below, in the order you need it. Fetch it fresh rather than trusting a cached copy across versions. Canonical location: https://kinl.dev/llms.txt ## Fast facts | | | | --- | --- | | Base URL | `https://api.kinl.dev/v1` (`https://kinl.dev/v1` also works) | | Auth | `Authorization: Bearer sk-kinl-...` | | Protocol | HTTP/1.1 and HTTP/2, JSON in, JSON out | | Streaming | Server-sent events on chat, completions and responses | | SDK | Any OpenAI SDK. No kinl-specific library exists or is needed. | | Pricing | USD, charged from prepaid credit, per request | | Credit | Prepaid and non-refundable; usable only for model usage. Failed or cancelled requests are not charged | | Catalogue | Live counts per category: `GET https://kinl.dev/api/models`. Do not hard-code a total; it moves daily. | | Rate limit | 300-900 requests/minute depending on plan, per client | | Docs | https://docs.kinl.dev | | Connectors | https://connect.kinl.dev | | Dashboard | https://kinl.dev/dashboard | Use `https://api.kinl.dev/v1` as the base URL for all V1 inference calls (and `https://api.kinl.dev` for SDKs that append `/v1/...` themselves). `https://kinl.dev/v1` remains available as an alias for existing integrations. ## Quickstart ### curl ```bash curl https://api.kinl.dev/v1/chat/completions \ -H "Authorization: Bearer $KINL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai-gpt-oss-20b", "messages": [{"role": "user", "content": "Explain vector embeddings in two sentences."}] }' ``` ### Python, using the OpenAI SDK ```python import os from openai import OpenAI client = OpenAI( base_url="https://api.kinl.dev/v1", api_key=os.environ["KINL_API_KEY"], ) reply = client.chat.completions.create( model="openai-gpt-oss-20b", messages=[{"role": "user", "content": "Explain vector embeddings in two sentences."}], ) print(reply.choices[0].message.content) ``` ### Node, using the OpenAI SDK ```js import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.kinl.dev/v1", apiKey: process.env.KINL_API_KEY, }); const reply = await client.chat.completions.create({ model: "openai-gpt-oss-20b", messages: [{ role: "user", content: "Explain vector embeddings in two sentences." }], }); console.log(reply.choices[0].message.content); ``` ### Any client that reads OPENAI_BASE_URL Most tools accept a base URL and a key from the environment and need no code change at all: ```bash export OPENAI_BASE_URL="https://api.kinl.dev/v1" export OPENAI_API_KEY="sk-kinl-your-key" ``` If a tool instead asks for `OPENAI_API_BASE`, `LLM_BASE_URL` or a "custom provider", the value is the same base URL above and the key goes wherever it asks for an API key. ## Authentication Every request under `/v1` needs: ``` Authorization: Bearer sk-kinl- ``` Rules that matter when writing code: - The key is a bearer token. Never send it in a query string, never log it. - Keys are per environment. A key can be scoped to a subset of models, so a key that works for one model may return `403 model_not_allowed` for another. Treat 403 as "this key is not provisioned for that model", not as an auth failure. - A revoked key returns `401`. There is no grace period. - The balance belongs to the account, not the key. Two keys share one balance. Public endpoints, no key needed: `GET https://kinl.dev/api/models`, `GET https://kinl.dev/api/plans`, `GET https://kinl.dev/api/config`, `GET https://kinl.dev/health`. Everything under `/v1` needs a key, including `GET /v1/models`. ## Endpoints All paths below are relative to the base URL `https://api.kinl.dev/v1` unless shown in full. | Method | Path | Body | Returns | | --- | --- | --- | --- | | POST | `/chat/completions` | JSON | Chat completion, or an SSE stream | | POST | `/completions` | JSON | Legacy text completion | | POST | `/responses` | JSON | Responses-API shaped reply | | POST | `/embeddings` | JSON | Vector embeddings | | GET | `/models` | none | Model ids. Auth required, no prices. | | POST | `/images/generations` | JSON | One or more images | | POST | `/images/edits` | multipart | Edited image | | POST | `/audio/speech` | JSON | Raw audio bytes | | POST | `/audio/transcriptions` | multipart | Transcript text | | POST | `/video/generations` | JSON | A job handle, poll for the result | | POST | `/music/generations` | JSON | A job handle, poll for the result | | GET | `/v1/:kind/generations/:id` | none | Job status; `:kind` is `video` or `music` | | DELETE | `/v1/:kind/generations/:id` | none | Cancels the job and releases the hold | | GET | `/v1/media/artifacts/:jobId/:index` | none | The finished media file | `GET https://kinl.dev/health` returns liveness. It needs no key. `/audio/transcriptions` needs an audio model priced per `minute`. If the catalogue currently lists only speech models, the call is refused with `403 model_not_allowed` rather than silently substituted — check `category: "audio"` and `mediaUnit` before wiring it up. ## Model catalogue There are two catalogue views, and they answer different questions. `GET /v1/models` is the OpenAI-compatible listing. It needs a key and returns only what a client needs to enumerate choices: ```json { "object": "list", "data": [ { "id": "openai-gpt-oss-20b", "object": "model", "owned_by": "kinl", "context_length": 128000 } ] } ``` `https://kinl.dev/api/models` is the richer, public view. It needs no key and is the one to read when you need prices, categories or capabilities: ```json { "data": [ { "id": "openai-gpt-oss-20b", "name": "GPT OSS 20B", "provider": "OpenAI", "category": "chat", "contextLength": 128000, "capabilities": ["streaming", "tools"], "pricing": { "inputPer1mMicro": 21, "outputPer1mMicro": 103, "mediaPerUnitMicro": null, "mediaUnit": null } } ] } ``` Money in `/api/models` is in micro-dollars: `1000000` is `$1`, so an `inputPer1mMicro` of `21` is `$0.000021` per 1M input tokens. The response also carries `total`, the number of entries returned for the filter you asked for. `category` is one of `chat`, `image`, `video`, `music`, `audio`, `embedding`. `capabilities` may contain `streaming`, `tools`, `vision`, `reasoning`. A model priced per unit rather than per token carries `mediaPerUnitMicro` and `mediaUnit`, and leaves the token rates zero. `mediaUnit` is one of: | `mediaUnit` | Charged per | Set by | | --- | --- | --- | | `job` | one finished generation | video and music | | `image` | one image returned | `n` in an image request | | `megapixel` | one megapixel of output | the `size` you ask for | | `minute` | one minute of audio processed | the duration of the upload | | `1K characters` | one thousand characters of input text | the length of `input` | Choose the pricing branch by which one is non-zero; do not assume token pricing. Some image models are priced per `image` and others per `megapixel`, so read the unit rather than assuming one for the whole category. ### Cheapest chat models Prices below are per 1M tokens, USD, retail. They move; read them from `/api/models` at build time rather than hard-coding. | Model | Input | Output | Context | Capabilities | | --- | --- | --- | --- | --- | | `openai-gpt-oss-20b` | 0.000021 | 0.000103 | 128k | streaming, tools | | `openai-gpt-oss-120b` | 0.000080 | 0.000342 | 128k | streaming, tools | | `openai-gpt-oss-safeguard-20b` | 0.000086 | 0.000342 | 128k | streaming, tools | | `glm-4.5-air` | 0.000149 | 0.000969 | 128k | streaming, tools, reasoning | | `qwen3.8-omni-flash` | 0.000205 | 0.000642 | 1M | streaming, tools, vision, reasoning | | `deepseek-v4.1-flash` | 0.000206 | 0.001581 | 1M | streaming, tools, vision, reasoning | | `qwen-3-8-27b` | 0.000228 | 0.002847 | 262k | streaming, tools, vision, reasoning | | `glm-4.7-flash` | 0.000356 | 0.002346 | 198k | streaming, tools | | `minimax-m2.1` | 0.000410 | 0.001638 | 198k | streaming, tools, reasoning | For a workload that is mostly short chat turns, the per-request minimum charge dominates and the model choice barely moves the bill. For long prompts, input price dominates. Measure before optimising. Entry points in the other categories, for orientation: - Image, per image: `venice-flux-1.1-pro`, `seedream-4.5` - Image, per megapixel: `flux.2-klein-4b`, `flux.2-flex` - Image editing: `nano-banana-pro-edit`, `qwen-image-2-pro-edit` (multipart) - Image, token-priced: `gemini-2.5-flash-image`, `gpt-5-image-mini` - Video: `grok-imagine-text-to-video` (prompt only), `longcat-distilled-image-to-video` (cheapest, needs an image) - Music: `venice-mmaudio-v2-text-to-audio` (cheapest per job) - Speech: `venice-kokoro-tts` (per 1K characters) - Embedding: `venice-embed-1` ## Streaming Set `"stream": true` on `/chat/completions`, `/completions` or `/responses` and the response is `text/event-stream`. Frames are OpenAI-shaped `data: {...}` lines terminated by `data: [DONE]`. Read them with the OpenAI SDK's normal streaming helper; nothing is different. ```python stream = client.chat.completions.create( model="openai-gpt-oss-20b", messages=[{"role": "user", "content": "Count to five."}], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content or "", end="") ``` Usage is metered after the stream finishes. A stream that the client cancels or that breaks before it finishes is not charged. ## Async media `/video/generations` and `/music/generations` do not block. They return a job: ```json { "id": "job_01J8Z9K3", "object": "video.job", "model": "seedance-1-5-pro-image-to-video", "status": "queued", "poll_after_ms": 2000, "results": null, "error": null } ``` Poll `GET /v1/video/generations/job_01J8Z9K3` (or `/music/...`) until `status` is `succeeded`, `failed`, `cancelled` or `expired`. A succeeded job fills `results` with one entry per artifact: ```json "results": [ { "index": 0, "url": "/v1/media/artifacts/job_01J8Z9K3/0" } ] ``` Download those with the same bearer key. Honour `poll_after_ms` rather than picking your own interval; do not poll faster than once every two seconds. `DELETE` the job URL to cancel it. A job that ends `failed`, `cancelled` or `expired` is not charged, and the amount held when you submitted it is released. A succeeded job is charged per `job` at the price in the catalogue. Artifacts are not kept forever. A job whose files have been cleared answers `410 artifact_expired`, so download as soon as `status` is `succeeded`. ## Pricing The bill for one request is: ``` charge = max( usage + per_request_fee , minimum_charge ) ``` - `usage` is the model's published rate multiplied by the tokens or units used, taken from the catalogue above. The published rate is the final rate; nothing is added on top of it. - `per_request_fee` and `minimum_charge` come from your plan. - `minimum_charge` is a floor, so no request is free to serve. - Usage is metered in micro-dollars and rounded up per token class, so a bill can land a few micro-dollars above a straight multiplication. Plans, as of this version: | Plan | Price/month | Credit included | Per request | Minimum | | --- | --- | --- | --- | --- | | Pay as you go | 0 | 0 | $0.0005 | $0.0010 | | Starter | $19 | $19.90 | $0.0004 | $0.0008 | | Studio | $49 | $51.00 | $0.0003 | $0.0006 | | Scale | $149 | $156.00 | $0.0002 | $0.0004 | `GET https://kinl.dev/api/plans` returns the live numbers in micro-dollars (1000000 = $1). Read it rather than trusting this table. Worked examples, pay-as-you-go: - 500 input and 200 output tokens on `openai-gpt-oss-20b` is about two micro-dollars of usage ($0.000002). Add the $0.0005 fee and the total is still under the floor, so the bill is $0.0010. Short requests are priced by the floor. - 1M input and 1M output tokens on `deepseek-v4.1-flash` is $0.001787 of usage ($0.000206 in + $0.001581 out), plus the $0.0005 fee, so the bill is $0.002287. Above the floor, usage is what you pay. Practical consequence: batch or cache long prompts, and do not fan out to many tiny requests when one larger request would do. ## Routing Each key has a routing mode, set in the dashboard when the key is created: - `exact` - always call the model named in the request. This is the default. - `family` - serve the cheapest model from the same family that reaches the same route. One model can be replaced by a cheaper model from the same family, never by a model from a different family. - `market` - serve the cheapest model anywhere in the catalogue that reaches the same route and satisfies the request. Two constraints are deliberate and worth knowing before you rely on this: - Substitution never crosses a billing unit. A chat request is never answered by an image model, however cheap that model is. - Substitution never widens a key's allowlist. A key scoped to three models only ever gets one of those three. When a substitution happens the response says so, in a header and in the body: ``` X-Kinl-Model: qwen3.8-omni-flash X-Kinl-Routed: cheapest in market ``` `X-Kinl-Routed` is `cheapest in family` for `family` mode and `cheapest in market` for `market` mode. Both headers are absent when the requested model was served unchanged, so a missing header means you got what you asked for. Log them either way: when a bill looks wrong, they explain it. Do not hard-code model names in a client that uses `family` or `market` routing; read `X-Kinl-Model` instead. ## Virtual routes Customers can define named virtual models (`route/`) in the dashboard under API keys -> Virtual routes (or via `/api/routes`). Each route combines 1-8 targets across own provider keys (`byok/...`), marketplace offers, and the catalogue behind one stable model id, and appears in `GET /v1/models`: - Strategies: `fallback` (try in order), `weighted` (proportional traffic split with automatic failover), or `cheapest` (lowest live per-request estimate). - Pre-first-byte failover automatically advances on 429, 5xx, empty balance, or TTFT timeout without ever failing over once response bytes have started. - Optional per-route `ttftTimeoutMs` (100-120000 ms) and cache policy (`inherit`, `on`, or `bypass`). - Responses include `X-Kinl-Route: `, `X-Kinl-Model`, and `X-Kinl-Routed`. ## Caching & request coalescing Non-streaming embeddings and deterministic completions (`temperature: 0`) are cached per account automatically, and concurrent identical requests are coalesced into one execution: - Request headers: `X-Kinl-Cache: on | bypass | refresh`, `X-Kinl-Cache-TTL: `. - Response headers: `X-Kinl-Cache: HIT | MISS | COALESCED | BYPASS`, `X-Kinl-Cache-Age: `. - `HIT` and `COALESCED` responses are billed $0 and strictly isolated per account. ## Latency, cost tagging & pre-first-byte failover - `X-Kinl-TTFT-Ms` reports time to first byte (ms); `X-Kinl-TPS` reports output tokens/sec on non-streaming responses. Both appear in Dashboard -> Requests and Dashboard -> Usage. - `X-Kinl-Tag` (up to 64 chars) attaches a cost-attribution tag to any request for per-feature, per-environment, or per-tenant breakdowns in Dashboard -> Usage and CSV exports (`/api/requests/export`). Falls back to `metadata.tag`, `metadata.user_id`, or the OpenAI `user` field when the header is absent. - `X-Kinl-TTFT-Timeout-Ms` (100-120000 ms) aborts a stalling target before the first byte and fails over to the next key or target in a BYOK pool, `X-Kinl-Fallback` chain, or `route/`. ## Webhooks Configure up to ten public HTTPS endpoints in the dashboard under API keys -> Webhooks (or `/api/webhooks`). Every POST carries `X-Kinl-Event`, `X-Kinl-Event-Id`, `X-Kinl-Delivery`, and `X-Kinl-Signature: t=,v1=` (HMAC-SHA256 of `${t}.${rawBody}` with the endpoint's `whsec_...` secret). Failed deliveries retry up to four times with exponential backoff; redirects are never followed. - Events: `balance.low`, `cap.reached`, `byok.key_invalid`, `route.failover`, plus `webhook.test` via `POST /api/webhooks/:id/test`. ## Your own keys Customers can add one or more keys per provider (OpenAI, Anthropic, Google Gemini, Mistral, xAI, DeepSeek, Groq, OpenRouter, Together, Fireworks, or any OpenAI-compatible endpoint) in the dashboard under API keys -> Your provider keys. The kinl key still authenticates; the provider key never leaves kinl. - `byok//` (for example `byok/openai/gpt-4o-mini`) always runs on the caller's own key pool for that provider, using the provider's model id. - Multiple keys for the same provider form a pool ordered by `priority` (1-1000, lower tried first) and balanced by `weight` (1-100). On 429/5xx, the failing key cools down and kinl fails over to the next healthy key. - Pass `X-Kinl-Fallback: byok//, ...` for cross-provider fallback on rate limits, outages, or TTFT timeouts. - For catalogue models, each key has a mode: `fallback` (default: used only when the balance does not cover the request or the model is unavailable), `always`, or `manual` (only `byok/` ids). - Supports chat completions, Responses, legacy completions, embeddings, and the Anthropic `/v1/messages` and Gemini-compatible routes. Responses carry `X-Kinl-Routed: your key ()`; kinl does not charge for those tokens. - Codes: `provider_key_missing` (400), `provider_key_rejected` (401), `provider_unreachable` (502), `byok_unavailable` (503). ## Errors Errors use the OpenAI envelope: ```json { "error": { "type": "invalid_request_error", "code": "invalid_request", "message": "model is required", "param": "model", "request_id": "req_01J8Z9K3", "hint": "Send a model id from the catalogue and try again." } } ``` `message` says what happened. `hint` says what to do about it, and is present on every failure. A 5xx also carries `report_url`, an absolute link to our bug board with `request_id` already attached. A 4xx does not. Both keys are additive and safe for a client that ignores unknown fields. | Status | Code | Meaning and what to do | | --- | --- | --- | | 400 | `invalid_request` | Malformed body or missing field. Read `param`. Do not retry. | | 401 | `invalid_api_key` | Key missing, wrong, or revoked. Do not retry. | | 402 | `insufficient_credit` | Balance too low for the estimated request. Top up, do not retry in a loop. | | 402 | `budget_exceeded` | A key or daily/monthly cap is hit. Wait for the window or raise the cap. | | 403 | `model_not_allowed` | This key is not provisioned for that model. Pick another or widen the key. | | 403 | `forbidden` | The account is not permitted to do this. Do not retry. | | 404 | `not_found` | Unknown path, model or job id. Do not retry. | | 409 | `conflict` | The request collides with one in flight, usually the same Idempotency-Key. Wait for the first to finish. | | 413 | `payload_too_large` | Body over the limit. Split it or use multipart. | | 429 | `rate_limit_exceeded` | Slow down. Honour `Retry-After`, then retry with backoff. | | 500 | `internal_error` | Fault on our side. Retry with backoff, then surface a plain message. | | 503 | `capacity_unavailable` | Capacity problem, not the caller's fault. Retry with backoff. | Always log `request_id`. It is the only handle support needs to trace a request. Retry policy that works: retry 429, 500 and 503 with exponential backoff and jitter, at most three times, and never retry 400, 401, 402, 403, 404 or 409. ## Limits - Request body size is enforced per route. Large audio and image uploads belong in multipart, not base64 inside JSON. - Rate limit is per client, not per key. Every response carries `X-RateLimit-Limit` (requests per minute) and `X-RateLimit-Reset` (unix seconds when the window turns over). - `Retry-After` on a 429 is in seconds. - Idempotency: send `Idempotency-Key: ` on a non-streaming POST to make a retry safe. Replaying the same key within 24 hours returns the first result instead of billing twice. A second request with the same key while the first is still running returns `409 idempotency_in_flight`. Streaming requests are not idempotent. ## MCP server kinl.dev also exposes its catalogue over the Model Context Protocol, so an assistant can answer "what does this cost" and "what am I allowed to call" without a browser. Transport is Streamable HTTP, JSON-RPC 2.0 over POST: ``` https://api.kinl.dev/mcp ``` Authenticate with the same bearer key. Six read-only tools: | Tool | Does | | --- | --- | | `list_models` | The catalogue at your prices, filtered by category, family, capability or a maximum input price | | `get_model` | One model in full: context window, capabilities, price | | `estimate_cost` | What one request will be billed, including the minimum charge | | `get_balance` | Available credit, active plan, and the rate you are on | | `get_usage` | Requests and spend for a window, broken down by model | | `list_keys` | Your keys, their routing mode and their caps. Never the secret. | Client configuration: ```json { "mcpServers": { "kinl": { "type": "http", "url": "https://api.kinl.dev/mcp", "headers": { "Authorization": "Bearer sk-kinl-your-key" } } } } ``` Every tool is a read, so a dropped connection costs nothing and nothing here can spend the balance. ## Ready-made prompts Copy one of these into an agent that can read a URL. Replace the key placeholder before sending. ### Add kinl to an existing project ``` Read https://kinl.dev/llms.txt, then change this project's model calls to use kinl.dev. Set the base URL to https://api.kinl.dev/v1, read the key from the KINL_API_KEY environment variable, and keep the OpenAI SDK - no new client library. Pick a model from the catalogue that is cheapest for our workload and tell me what you chose and why. ``` ### Scaffold a new project against kinl ``` Read https://kinl.dev/llms.txt and scaffold a small project that calls kinl.dev's chat completions with streaming. Use the OpenAI SDK, read the key from KINL_API_KEY, handle 429 and 503 with backoff, and print the X-Kinl-Model header so I can see what served each request. ``` ### Cut an existing bill ``` Read https://kinl.dev/llms.txt. Our current spend is dominated by long chat completions. Using the published prices, find the cheapest model in the catalogue that still supports tool calling and a 100k context, estimate the cost of our average request on it, and show me the before/after numbers before you change any code. ``` ### Switch a key to cheapest-in-market routing ``` Read https://kinl.dev/llms.txt. Our key is on exact routing and we are paying for a frontier model on classification jobs that do not need one. Tell me which routing mode fits, what it would have cost on the cheapest model that handles the same requests, and how to read X-Kinl-Model so our logs still show what actually served each call. ``` ### Wire up the MCP server ``` Read https://kinl.dev/llms.txt, then add the kinl MCP server to my editor config. Endpoint https://api.kinl.dev/mcp, bearer auth with the key in KINL_API_KEY, Streamable HTTP transport. After that, use its list_models and estimate_cost tools to tell me what our three most expensive calls cost. ``` ## Links - Dashboard: https://kinl.dev/dashboard - Model catalogue: https://kinl.dev/models - Pricing: https://kinl.dev/pricing - Documentation: https://docs.kinl.dev - Connectors: https://connect.kinl.dev - Machine-readable catalogue: https://kinl.dev/api/models - Plans, live: https://kinl.dev/api/plans - MCP endpoint: https://api.kinl.dev/mcp - Legal: https://kinl.dev/terms, https://kinl.dev/privacy, https://kinl.dev/cookies ## Optional - `https://kinl.dev/api/config` publishes non-secret runtime configuration: whether signup is open, the invoice currency, and the rate limit. Useful for a status page; not needed to integrate. - If you are generating code for a human, prefer `openai-gpt-oss-20b` in examples: it is the cheapest chat model, so a copy-pasted example costs almost nothing to run.