API Documentation
One API key. Access to Claude, GPT, Gemini, Grok, and more. Drop-in compatible with OpenAI and Anthropic SDKs.
OpenAI-compatible base URL: https://api.mitdotkey.com/v1
Anthropic-compatible base URL: https://api.mitdotkey.com
API Key: mdk-xxxxxxxxxx
Quick Start
Get your first API call running in under 2 minutes.
Create an account
Sign up at mitdotkey.com and verify your email. New accounts receive free credits to get started.
Get your API key
Go to Dashboard → API Keys and create a new key. Your key will look like mdk-xxxxxxxxxx. Keep it secret — treat it like a password.
Make your first call
Use an OpenAI-compatible SDK, an Anthropic-compatible SDK, or plain HTTP. Here is a minimal OpenAI-compatible example:
curl https://api.mitdotkey.com/v1/chat/completions \
-H "Authorization: Bearer mdk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"model":"aws/claude-sonnet-4-6","messages":[{"role":"user","content":"Hello!"}]}'
Claude Code (CLI)
Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY from your environment. Because Claude Code automatically appends /v1/messages, set the base URL without the /v1 suffix.
Method 1 — Environment variables
# Linux / macOS
export ANTHROPIC_BASE_URL=https://api.mitdotkey.com
export ANTHROPIC_API_KEY=mdk-xxxxxxxxxx
# Then launch Claude Code normally
claude
Add those lines to your ~/.bashrc or ~/.zshrc to make them permanent.
# Windows PowerShell
$env:ANTHROPIC_BASE_URL="https://api.mitdotkey.com"
$env:ANTHROPIC_API_KEY="mdk-xxxxxxxxxx"
Method 2 — --model flag
Pass the model directly when launching Claude Code:
claude --model aws/claude-opus-4-6
claude --model aws/claude-sonnet-4-6
claude --model aws/claude-haiku-4-5
Method 3 — settings.json
Edit ~/.claude/settings.json (create it if it does not exist). This sets both the base URL and API key persistently:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.mitdotkey.com",
"ANTHROPIC_API_KEY": "mdk-xxxxxxxxxx"
}
}
Important: Use https://api.mitdotkey.com (no /v1) as the base URL. Claude Code appends /v1/messages automatically.
Cursor IDE
Cursor supports custom OpenAI-compatible endpoints via its settings panel.
- Open Cursor Settings → Models
- Under OpenAI API Key, enter your MitdotKey key:
mdk-xxxxxxxxxx - Enable Override OpenAI Base URL and set it to:
https://api.mitdotkey.com/v1 - Click Verify to confirm the connection
- Select any model from the model list (e.g.
aws/claude-sonnet-4-6)
Tip: You can add custom model names in Cursor by typing them directly into the model input field.
Continue.dev
Add MitdotKey as a provider in your ~/.continue/config.json:
{
"models": [
{
"title": "Claude Sonnet 4.6 (MitdotKey)",
"provider": "openai",
"model": "aws/claude-sonnet-4-6",
"apiKey": "mdk-xxxxxxxxxx",
"apiBase": "https://api.mitdotkey.com/v1"
},
{
"title": "GPT-5.2 (MitdotKey)",
"provider": "openai",
"model": "gpt/gpt-5.2",
"apiKey": "mdk-xxxxxxxxxx",
"apiBase": "https://api.mitdotkey.com/v1"
}
],
"tabAutocompleteModel": {
"title": "Claude Haiku 4.5",
"provider": "openai",
"model": "aws/claude-haiku-4-5",
"apiKey": "mdk-xxxxxxxxxx",
"apiBase": "https://api.mitdotkey.com/v1"
}
}
Restart VS Code or your editor after saving the config. Continue will pick up the new provider automatically.
Cline / Roo Code
Both Cline and Roo Code support OpenAI-compatible providers.
- Open the extension settings panel (click the gear icon in the Cline/Roo sidebar)
- Set API Provider to OpenAI Compatible
- Set Base URL to
https://api.mitdotkey.com/v1 - Enter your API key:
mdk-xxxxxxxxxx - Set Model ID to your preferred model, e.g.
aws/claude-sonnet-4-6 - Click Save
Recommended model for coding: aws/claude-sonnet-4-6 offers the best balance of speed, quality, and cost for agentic coding tasks.
OpenClaw
Add MitdotKey as a provider in your OpenClaw config:
{
"models": {
"providers": {
"mitdotkey": {
"baseUrl": "https://api.mitdotkey.com/v1",
"apiKey": "mdk-xxxxxxxxxx",
"api": "openai-completions",
"models": [
{
"id": "aws/claude-opus-4-6",
"name": "Claude Opus 4.6 (AWS)",
"reasoning": true,
"input": ["text"],
"contextWindow": 1000000,
"maxTokens": 128000
}
]
}
},
"agents": {
"defaults": {
"model": {
"primary": "mitdotkey/aws/claude-opus-4-6"
}
}
}
}
}
Python
MitdotKey is fully compatible with the openai Python SDK. Install it with pip install openai.
Chat completion
from openai import OpenAI
client = OpenAI(
api_key="mdk-xxxxxxxxxx",
base_url="https://api.mitdotkey.com/v1",
)
response = client.chat.completions.create(
model="aws/claude-sonnet-4-6",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum entanglement in simple terms."},
],
max_tokens=512,
)
print(response.choices[0].message.content)
Streaming
from openai import OpenAI
client = OpenAI(
api_key="mdk-xxxxxxxxxx",
base_url="https://api.mitdotkey.com/v1",
)
with client.chat.completions.stream(
model="aws/claude-sonnet-4-6",
messages=[{"role": "user", "content": "Write a short poem about the ocean."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Vision (image input)
from openai import OpenAI
client = OpenAI(
api_key="mdk-xxxxxxxxxx",
base_url="https://api.mitdotkey.com/v1",
)
response = client.chat.completions.create(
model="gpt/gpt-5.2",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image_url",
"image_url": {"url": "https://example.com/photo.jpg"},
},
],
}
],
)
print(response.choices[0].message.content)
Node.js / TypeScript
Install the SDK with npm install openai.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "mdk-xxxxxxxxxx",
baseURL: "https://api.mitdotkey.com/v1",
});
async function main() {
const response = await client.chat.completions.create({
model: "aws/claude-sonnet-4-6",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "What is the capital of France?" },
],
max_tokens: 256,
});
console.log(response.choices[0].message.content);
}
main();
Streaming (Node.js)
const stream = await client.chat.completions.create({
model: "aws/claude-sonnet-4-6",
messages: [{ role: "user", content: "Tell me a joke." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
Anthropic SDK
Use the Anthropic Messages API surface when your app or agent expects /v1/messages, x-api-key, and anthropic-version. Set the base URL to https://api.mitdotkey.com without the /v1 suffix because Anthropic SDKs append the versioned path internally.
Python
from anthropic import Anthropic
client = Anthropic(
api_key="mdk-xxxxxxxxxx",
base_url="https://api.mitdotkey.com",
)
message = client.messages.create(
model="aws/claude-sonnet-4-6",
max_tokens=512,
messages=[
{"role": "user", "content": "Explain quantum entanglement in simple terms."}
],
)
print(message.content[0].text)
Node.js / TypeScript
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: "mdk-xxxxxxxxxx",
baseURL: "https://api.mitdotkey.com",
});
const message = await anthropic.messages.create({
model: "aws/claude-sonnet-4-6",
max_tokens: 512,
messages: [
{ role: "user", content: "Explain quantum entanglement in simple terms." },
],
});
console.log(message.content[0].type === "text" ? message.content[0].text : message.content);
cURL
OpenAI-compatible
curl https://api.mitdotkey.com/v1/chat/completions \
-H "Authorization: Bearer mdk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "aws/claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, how are you?"}
],
"max_tokens": 256
}'
Anthropic-compatible
curl https://api.mitdotkey.com/v1/messages \
-H "x-api-key: mdk-xxxxxxxxxx" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "aws/claude-sonnet-4-6",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
],
"max_tokens": 256
}'
Function Calling
MitdotKey supports OpenAI-style tool/function calling across all compatible models.
from openai import OpenAI
import json
client = OpenAI(
api_key="mdk-xxxxxxxxxx",
base_url="https://api.mitdotkey.com/v1",
)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city name, e.g. 'Hanoi'",
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
},
},
"required": ["city"],
},
},
}
]
response = client.chat.completions.create(
model="aws/claude-sonnet-4-6",
messages=[{"role": "user", "content": "What is the weather in Hanoi?"}],
tools=tools,
tool_choice="auto",
)
message = response.choices[0].message
if message.tool_calls:
tool_call = message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
print(f"Function: {tool_call.function.name}")
print(f"Arguments: {args}")
Image Generation
Generate images using the POST /v1/images/generations endpoint. The request format follows the OpenAI images API.
Available models
| Model ID | Resolution | Price |
|---|---|---|
gemini-2.5-flash-image | 1024×1024 | $0.25 / request |
gemini-image-1k | 1408×768 | $0.36 / request |
gemini-image-2k | 2816×1536 | $0.45 / request |
gemini-image-4k | 5632×3072 | $0.50 / request |
gpt-image-1.5 | 1024×1024 | $0.36 / request |
max/gemini-3.1-image-1k | 1408×768 | $0.49 / request |
max/gemini-3.1-image-2k | 2816×1536 | $0.65 / request |
max/gemini-3.1-image-4k | 5632×3072 | $0.81 / request |
max/gpt-image-1.5 | 1024×1024 | $0.49 / request |
max/nano-banana-2-1k | 1408×768 | $0.65 / request |
max/sora-image | 1024×1024 | $0.49 / request |
Example
from openai import OpenAI
client = OpenAI(
api_key="mdk-xxxxxxxxxx",
base_url="https://api.mitdotkey.com/v1",
)
response = client.images.generate(
model="gemini-2.5-flash-image",
prompt="A serene mountain lake at sunrise, photorealistic, 4K",
n=1,
size="1024x1024",
)
print(response.data[0].url)
Note: Image URLs returned are temporary. Download and store them if you need them long-term.
Video Generation
Video generation is asynchronous. Submit a job with POST /v1/video/create, then poll GET /v1/videos/:task_id until the status is completed.
Available models
| Model ID | Duration | Resolution | Price |
|---|---|---|---|
imy/grok-video-3 | 6s | 720p | $0.36 / video |
imy/veo_3_1-fast-slow | 5s | 720p | $0.90 / video |
imy/veo_3_1-fast-premium | 5s | 720p | $2.25 / video |
max/veo-3.1 | 8s | 720p HQ | $1.80 / video |
Async workflow example
import time
import requests
API_KEY = "mdk-xxxxxxxxxx"
BASE = "https://api.mitdotkey.com/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
# Step 1: Submit the job
resp = requests.post(f"{BASE}/video/create", headers=HEADERS, json={
"model": "max/veo-3.1",
"prompt": "A golden retriever running on a beach at sunset, cinematic",
})
resp.raise_for_status()
task_id = resp.json()["task_id"]
print(f"Job submitted: {task_id}")
# Step 2: Poll until done
while True:
status_resp = requests.get(f"{BASE}/videos/{task_id}", headers=HEADERS)
data = status_resp.json()
state = data.get("status")
print(f"Status: {state}")
if state == "completed":
print(f"Video URL: {data['url']}")
break
elif state == "failed":
print(f"Error: {data.get('error')}")
break
time.sleep(5)
API Endpoints
OpenAI-compatible endpoints are relative to https://api.mitdotkey.com/v1. Anthropic-compatible SDKs use https://api.mitdotkey.com as the base URL and call /v1/messages internally.
| Method | Endpoint | Description |
|---|---|---|
| POST | /chat/completions |
Chat completions — main LLM endpoint, OpenAI-compatible |
| POST | /messages |
Messages API — Anthropic-compatible chat endpoint |
| POST | /completions |
Legacy text completions |
| POST | /embeddings |
Generate text embeddings |
| POST | /images/generations |
Generate images from a text prompt |
| POST | /video/create |
Submit an async video generation job |
| GET | /videos/:task_id |
Poll video generation job status and retrieve URL |
| POST | /audio/speech |
Text-to-speech synthesis |
| POST | /audio/transcriptions |
Speech-to-text transcription (Whisper-compatible) |
| GET | /models |
List all available models |
Popular models
| Model ID | Name | Input | Output |
|---|---|---|---|
aws/claude-opus-4-6 | Claude Opus 4.6 | $5 / M tokens | $25 / M tokens |
aws/claude-sonnet-4-6 | Claude Sonnet 4.6 | $3 / M tokens | $15 / M tokens |
aws/claude-haiku-4-5 | Claude Haiku 4.5 | $1 / M tokens | $5 / M tokens |
gpt/gpt-5.2 | GPT-5.2 | $1.75 / M tokens | $14 / M tokens |
gem/gemini-3.1-pro-preview | Gemini 3.1 Pro | $3 / M tokens | $18 / M tokens |
xai/grok-4.1 | Grok 4.1 | $4.50 / M tokens | $22.50 / M tokens |
Error Codes
Errors include an HTTP status code and a JSON body with a readable message. OpenAI-compatible endpoints return the OpenAI-style shape shown below; Anthropic-compatible SDKs surface the same failures by status code and message.
| HTTP Status | Meaning | Resolution |
|---|---|---|
401 |
Invalid API key | Check that your key starts with mdk- and is copied correctly |
402 |
Insufficient balance | Top up your account at Dashboard → Top Up |
403 |
Account locked | Contact support — your account may have been flagged for review |
429 |
Rate limit exceeded | Slow down requests or contact support to increase your rate limit |
502 |
Upstream provider error | The upstream model provider returned an error — retry with exponential backoff |
Example error response
{
"error": {
"message": "Incorrect API key provided. Please check your key and try again.",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}