ChatyfAI API Reference

Access all AI models through a single, OpenAI-compatible API. Pay per token with CYT.

Base URL

https://api.chatyfai.com/v1

Authentication

All API requests require a Bearer token in the Authorization header. API keys start with sk-cyf-.

bash
curl https://api.chatyfai.com/v1/chat/completions \
  -H "Authorization: Bearer sk-cyf-live-your-api-key-here" \
  -H "Content-Type: application/json"

Security: Never share your API key. Use environment variables. Keys starting with sk-cyf-test- are for sandbox (no billing).

Chat Completions

POST/v1/chat/completions

Creates a chat completion. Compatible with the OpenAI API format.

Request

json
{
  "model": "gpt-5",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "stream": false,
  "temperature": 0.7,
  "max_tokens": 1000
}

Response

json
{
  "id": "cyf-cmpl-abc123",
  "object": "chat.completion",
  "model": "gpt-5",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "Hello! How can I help?"},
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 12,
    "total_tokens": 36,
    "chatyfai_tokens": {
      "input_cyt": 1,
      "output_cyt": 2,
      "total_cyt": 3,
      "balance_remaining_cyt": "99997"
    }
  }
}

Available Models

ModelProviderInput CYT/1KOutput CYT/1K
gpt-5OpenAI25100
gpt-5-miniOpenAI26
claude-sonnet-4-20250514Anthropic30150
claude-3-haiku-20240307Anthropic312
gemini-2.0-flashGoogle14
mistral-large-latestMistral2060
deepseek-chatDeepSeek13

List Models

GET/v1/models

Returns a list of all available models with their capabilities and CYT pricing.

bash
curl https://api.chatyfai.com/v1/models \
  -H "Authorization: Bearer sk-cyf-live-xxx"

Usage & Balance

GET/v1/balance

Check your current CYT balance and monthly usage.

GET/v1/usage?from=2026-01-01&to=2026-03-01

Detailed usage breakdown by model and provider.

GET/v1/billing/transactions

CYT transaction history (top-ups, consumption, refunds).

CYT Token System

ChatyfAI uses CYT (ChatyfAI Tokens) as a universal billing unit. Each AI model has its own CYT rate per 1,000 tokens.

How billing works

Cost = (input_tokens / 1000 x input_cyt_rate) + (output_tokens / 1000 x output_cyt_rate)

Example: 500 input + 200 output tokens with GPT-5 = (500/1000 x 25) + (200/1000 x 100) = 12.5 + 20 = 33 CYT

Error Handling

StatusCodeDescription
401invalid_api_keyMissing or invalid API key
402insufficient_balanceNot enough CYT balance
429rate_limit_exceededToo many requests per minute
400invalid_requestInvalid request parameters
503model_unavailableModel temporarily unavailable

Code Examples

Python (OpenAI SDK)

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-cyf-live-your-key",
    base_url="https://api.chatyfai.com/v1"
)

response = client.chat.completions.create(
    model="gpt-5",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

Node.js (OpenAI SDK)

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-cyf-live-your-key',
  baseURL: 'https://api.chatyfai.com/v1',
});

const response = await client.chat.completions.create({
  model: 'gpt-5',
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);

cURL

bash
curl -X POST https://api.chatyfai.com/v1/chat/completions \
  -H "Authorization: Bearer sk-cyf-live-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [{"role": "user", "content": "Explain AI"}],
    "max_tokens": 500
  }'

Ready to start?

Create a free account and get your API key in seconds.

Get API Key