Balance is deducted per API request based on token usage. Top up via USDT (TRC-20) on the Deposit tab.
Send USDT on the TRC-20 network to this address. Your TMT balance will be credited automatically within 1-2 minutes after confirmation.
All models available for use via the API. Prices are per 1 million tokens and update automatically.
Everything you need to integrate AI Gateway into your application.
# Replace YOUR_API_KEY with your key from the API Keys tab
curl -X POST /v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.1-70b",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
# Streaming
curl -X POST /v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.1-70b",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
# pip install openai
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="/v1",
)
# Regular request
response = client.chat.completions.create(
model="llama-3.1-70b",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
# Streaming
stream = client.chat.completions.create(
model="llama-3.1-70b",
messages=[{"role": "user", "content": "Explain quantum physics"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "/v1",
});
// Regular request
const response = await client.chat.completions.create({
model: "llama-3.1-70b",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
// Streaming
const stream = await client.chat.completions.create({
model: "llama-3.1-70b",
messages: [{ role: "user", content: "Explain quantum physics" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
For embedding models (e.g. nomic-embed-text, mxbai-embed-large) use POST /v1/embeddings. Billed by input tokens only (no output tokens).
# Single string
curl -X POST /v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nomic-embed-text",
"input": "Text to embed"
}'
# Batch (array of strings)
curl -X POST /v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nomic-embed-text",
"input": ["First text", "Second text", "Third text"]
}'
# pip install openai
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="/v1",
)
# Single string
result = client.embeddings.create(
model="nomic-embed-text",
input="Text to embed",
)
vector = result.data[0].embedding
print(f"Vector length: {len(vector)}")
# Batch
result = client.embeddings.create(
model="nomic-embed-text",
input=["First text", "Second text", "Third text"],
)
for item in result.data:
print(f"[{item.index}] len={len(item.embedding)}")
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "/v1",
});
// Single string
const result = await client.embeddings.create({
model: "nomic-embed-text",
input: "Text to embed",
});
console.log("Vector length:", result.data[0].embedding.length);
// Batch
const batch = await client.embeddings.create({
model: "nomic-embed-text",
input: ["First text", "Second text", "Third text"],
});
batch.data.forEach(item => {
console.log(`[${item.index}] len=${item.embedding.length}`);
});
See the Models tab for the full list with prices. Or fetch via API:
curl /v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Pass your API key in the Authorization header:
Authorization: Bearer gw_your_api_key_here
API keys start with gw_. Never share your key — it grants full access to your balance.
402 Payment Required.| Code | Meaning | Fix |
|---|---|---|
401 | Invalid or revoked API key | Check key on API Keys tab |
402 | Insufficient balance | Top up via Deposit tab |
404 | Model not found | Check model name via GET /v1/models |
503 | All providers unavailable | Retry in a few minutes |