Skip to main content
Sandbox tokens let you test your integration without real provider calls and at no cost. Requests made with a sandbox token return simulated data, so you can build and validate your workflow before going to production.

Token Types

Eden AI supports two token types:
Token TypePurposeReal Provider CallsCost
api_tokenProduction useYesPay-per-use
sandbox_api_tokenTesting and developmentNoFree
When you use a sandbox token, Eden AI returns mock responses that match the real response structure. This means your code works the same way in development and production — you just swap the token.

Creating a Sandbox Token

You can create sandbox tokens from the Eden AI dashboard under API Keys, or programmatically via the API:
import requests

url = "https://api.edenai.run/v2/user/custom_token/"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

payload = {
    "name": "dev-testing",
    "token_type": "sandbox_api_token"
}

response = requests.post(url, headers=headers, json=payload)
sandbox_token = response.json()
print(f"Sandbox token: {sandbox_token['token']}")

Using a Sandbox Token

Usage is identical to a production token — just use the sandbox token in the Authorization header:
import requests

url = "https://api.edenai.run/v3/llm/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_SANDBOX_TOKEN",
    "Content-Type": "application/json"
}

payload = {
    "model": "openai/gpt-4",
    "messages": [
        {"role": "user", "content": "Hello!"}
    ]
}

response = requests.post(url, headers=headers, json=payload)
result = response.json()

# Returns simulated data — same structure as a real response
print(result["choices"][0]["message"]["content"])

Multi-Environment Setup

A common pattern is to create one sandbox token per environment and swap to a production token when you go live:
import os

# Use a sandbox token in dev/staging, a real token in production
EDENAI_TOKEN = (
    os.getenv("EDENAI_SANDBOX_TOKEN")
    if os.getenv("ENV") != "production"
    else os.getenv("EDENAI_API_TOKEN")
)

headers = {"Authorization": f"Bearer {EDENAI_TOKEN}"}
You can create multiple sandbox tokens — one per app or environment — from the dashboard or via the API with different name values.

When to Use Sandbox Tokens

Development

Build and iterate on your integration without spending credits.

CI/CD Pipelines

Run automated tests against the API without incurring costs.

Demos

Show your integration to stakeholders with predictable responses.

Prototyping

Validate your architecture and request flow before going live.
Sandbox tokens return simulated data. The response structure matches production responses, but the actual content is mock data. Do not use sandbox tokens to evaluate model quality or accuracy.