Authentication
All API requests require an API key passed in the x-api-key header.
Getting Your API Key
- Go to your Profile > API Keys
- Click "Create New Key"
- Copy the key (shown only once)
- Store it securely — never expose it in client-side code
Making Requests
cURL
curl -X POST https://www.turingmate.com/api/v1/chat \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"characterId": "abc123", "message": "Hello!"}'JavaScript (fetch)
const response = await fetch("https://www.turingmate.com/api/v1/chat", {
method: "POST",
headers: {
"x-api-key": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
characterId: "abc123",
message: "Hello!",
}),
});
const data = await response.json();
console.log(data.message.content);Python (requests)
import requests
response = requests.post(
"https://www.turingmate.com/api/v1/chat",
headers={
"x-api-key": "your_api_key",
"Content-Type": "application/json",
},
json={
"characterId": "abc123",
"message": "Hello!",
},
)
data = response.json()
print(data["message"]["content"])Access Modes
Each API key has an access mode that controls which characters it can access:
| Mode | Description |
|---|---|
| own_only | Only characters you created (default) |
| own_and_presets | Your characters + official preset characters |
| all | All accessible characters (same as web UI) |
Error Responses
Invalid or missing API keys return a 401 status:
401 Unauthorized
{
"error": "Unauthorized"
}