Get up and running with our API in minutes. Follow this guide to create your account, generate an API key, and make your first ** request.**

Step 1
Create Account

Sign up in seconds to access your personal dashboard and start building.

Step 2
Choose Your Plan
Select the subscription tier that fits your needs. Change anytime.
Step 3
Generate API Key

Create secure keys to authenticate your API requests instantly.

Here's a complete example showing how to execute a message request. Replace <YOUR_API_KEY> with your actual API key.

Execute Message Endpoint

POST request to /api/v1/messages

bash
curl -X POST "https://api.tokenthon.com/api/v1/messages" \
    -H "Content-Type: application/json" \
    -H "x-api-key: <YOUR_API_KEY>" \
    -d '{
        "model": "gpt-auto",
        "messages": [{
        "role": "user",
        "content": "Write a one-sentence bedtime story about a unicorn."
        }],
        "response_format": { "format": "text" },
        "message_cache_ttl": 300,
        "timeout": 90
    }'

Request Parameters Explained

model

The AI model to use. gpt-auto automatically selects the best model.

messagesArray of conversation messages with role and content. Supports four roles: system, developer, assistant, and user.
message_cache_ttlCache duration in seconds (default: 300).
timeoutMaximum execution time in seconds (default: 90).

All Tokenthon models support a comprehensive multi-role message system for richer conversations:

RoleDescription
systemHigh-level system instructions that set overall AI behavior and personality
developerDeveloper-provided instructions for task-specific guidance or formatting requirements
assistantAI-generated responses, used to maintain conversation history
userEnd-user messages and queries (at least one required)

bash
curl -X POST "https://api.tokenthon.com/api/v1/messages" \
    -H "Content-Type: application/json" \
    -H "x-api-key: <YOUR_API_KEY>" \
    -d '{
        "model": "gpt-auto",
        "messages": [
            {
                "role": "system",
                "content": "You are a helpful coding assistant."
            },
            {
                "role": "developer",
                "content": "Provide code examples in TypeScript. Keep responses concise."
            },
            {
                "role": "user",
                "content": "How do I create a simple function in TypeScript?"
            }
        ],
        "response_format": { "format": "text" }
    }'

When you make a request to the API, you'll receive a JSON response with the following structure:

Example Response

Typical JSON response from the execute endpoint

json
{
    "success": true,
    "data": {
        "job_id": "c07748a4-7545-4d8d-8c9f-cc759a965d39",
        "status": "completed",
        "created_at": 1760814494529,
        "result": {
            "response_content": "Under a blanket of twinkling stars, a gentle unicorn named Luma painted the night sky with shimmering dreams so every child could fall asleep smiling."
        }
    },
    "message": "Job result retrieved successfully"
}

Ready to build something amazing?

Explore our full API documentation to unlock advanced features.

View API Reference