Get started
Authentication & SDKs
Send a key with every request, and scope each key to what it needs.
On this page
Authentication
Every endpoint except GET /models needs a key, sent as a bearer token:
Authorization: Bearer sk-dp-…Keys are stored hashed; the full key is shown once when you create it. Each key can be scoped in the dashboard:
| Setting | Effect |
|---|---|
| Spend limit | Per day, week, month or in total. Windows are UTC; weeks start on Monday. Requests over the limit get 402 key_limit_reached. |
| Allowed models | Only these slugs can be called. Empty means every published model. |
| IP allowlist | Exact IPv4/IPv6 addresses. Empty means any IP. |
| Expiry date | After it, the key gets 401 key_expired. |
| Provider policy | Verified providers only (no marketplace sellers) and/or no providers that log prompts. Also settable for the whole account. |
Disable a key to pause it, or delete it to revoke it for good; request history is kept either way. Key changes take effect within a few seconds. Up to 25 keys can be active per account.
Keep keys on the server
The gateway accepts browser (CORS) requests, but a key in client-side code can be read and spent by anyone. Call the API from your backend, or use a separate key with a low spend limit and an allowlist.
SDKs & frameworks
Anything that speaks the OpenAI Chat Completions API works: change the base URL and the key.
| Client | Configuration |
|---|---|
| OpenAI Python | OpenAI(base_url=…, api_key=…) |
| OpenAI Node / TypeScript | new OpenAI({ baseURL, apiKey }) |
| Vercel AI SDK | createOpenAICompatible({ name: "ditfa", baseURL, apiKey }) |
| LangChain | ChatOpenAI(base_url=…, api_key=…, model=…) |
| Tools that read env vars | OPENAI_BASE_URL=https://gateway.ditfa.com/v1 OPENAI_API_KEY=sk-dp-… |
Only Chat Completions is available. The Responses, Embeddings, Images and Audio endpoints of the OpenAI API are not served by the gateway.