API Documentation

OpenAI-compatible API. Change your base URL, keep your code, fund the planet.

Contents
Quick Start Base URL & Auth Auth Endpoints Chat Completions Models Balance & Deposits Pricing & Fee Split

Quick Start

EcoRouter is a drop-in replacement for the OpenAI API. If your code works with OpenAI, it works with EcoRouter.

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://api.ecorouter.org/v1",
    api_key="eco_sk_..."  # your EcoRouter API key
)

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

JavaScript (fetch)

const resp = await fetch("https://api.ecorouter.org/v1/chat/completions", {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer eco_sk_..."
    },
    body: JSON.stringify({
        model: "openai/gpt-4o-mini",
        messages: [{"role": "user", "content": "Hello!"}]
    })
});

cURL

curl https://api.ecorouter.org/v1/chat/completions \
  -H "Authorization: Bearer eco_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Base URL & Authentication

Base URL: https://api.ecorouter.org/v1
Auth: Authorization: Bearer eco_sk_...

All requests require an API key passed in the Authorization header. Get your key by signing up via the web UI or the /v1/auth/register endpoint.

Auth Endpoints

POST /v1/auth/register

Create a new account and get an API key.

ParameterTypeDescription
emailstringrequiredYour email address
passwordstringrequiredAt least 6 characters
# Request
curl -X POST https://api.ecorouter.org/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "secret123"}'

# Response
{
  "api_key": "eco_sk_a1b2c3...",
  "deposit_address": "TLqcLi5nz...",
  "deposit_hint": "Send any whole dollar amount + $0.042 cents (e.g. $10.042, $25.042)",
  "balance_usdt": 0
}
POST /v1/auth/login

Log in and retrieve your API key.

ParameterTypeDescription
emailstringrequiredYour email address
passwordstringrequiredYour password

Chat Completions

POST /v1/chat/completions

Generate a chat completion. Fully OpenAI-compatible.

This endpoint proxies directly to OpenRouter with your allocated credit. It supports all standard OpenAI parameters:

ParameterTypeDescription
modelstringrequiredModel ID, e.g. openai/gpt-4o, anthropic/claude-sonnet-4
messagesarrayrequiredArray of message objects with role and content
streambooleanStream response as SSE chunks
temperaturenumberSampling temperature (0-2)
max_tokensintegerMaximum tokens to generate
toolsarrayFunction calling / tool use definitions
Streaming: Set "stream": true for Server-Sent Events. Works with the OpenAI SDK's stream=True parameter out of the box.
POST /v1/embeddings

Generate embeddings. Same as OpenAI embeddings API.

Models

GET /v1/models

List all available models.

EcoRouter routes through OpenRouter, giving you access to 200+ models. Use the full model ID with the provider prefix:

ModelID
GPT-4oopenai/gpt-4o
GPT-4o Miniopenai/gpt-4o-mini
GPT-5openai/gpt-5
Claude Sonnet 4anthropic/claude-sonnet-4
Claude Opus 4anthropic/claude-opus-4
Gemini 2.5 Flashgoogle/gemini-2.5-flash
Gemini 2.5 Progoogle/gemini-2.5-pro
DeepSeek V3deepseek/deepseek-chat
DeepSeek R1deepseek/deepseek-r1
Llama 4 Maverickmeta-llama/llama-4-maverick

For the full list, call GET /v1/models or browse openrouter.ai/models.

Balance & Deposits

GET /v1/auth/balance

Check your credit balance and deposit info. Requires Authorization header.

# Response
{
  "api_credit_total_usdt": 8.90,
  "api_credit_used_usdt": 1.23,
  "api_credit_remaining_usdt": 7.67,
  "deposit_address": "TLqcLi5nz...",
  "deposit_cents_suffix": 42,
  "deposit_hint": "Send $X.042 to the deposit address"
}

Adding credits

Send USDT (TRC-20) to the deposit address shown in your balance response. Include your unique cents suffix so we can match the deposit to your account.

For example, if your suffix is 042, send $10.042, $25.042, etc. The deposit is credited automatically within ~60 seconds.

Fee split: 89% becomes your API credit, 10% goes to the eco fund (environmental donations), 1% covers operations. For a $10.042 deposit, you get $8.94 in API credits.

Pricing & Fee Split

EcoRouter charges the same per-token prices as the underlying providers (via OpenRouter). On top, there's an 11% fee split:

All eco fund transactions are public on the Tron blockchain. See the transparency page for details.

GET /v1/stats

Public endpoint. Returns platform stats, eco wallet address, fund rotation, and donation history. No auth required.