API Documentation

Everything you need to integrate TamgaLabs into your applications.

Quickstart

TamgaLabs is a fully OpenAI-compatible API gateway. All endpoints follow the OpenAI format. Just change the base_url and your API key.

curl https://tamgalabs.tr/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tamgalabs/gpt-5",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Base URL: https://tamgalabs.tr/api/v1

Authentication

All API requests require an API key passed as a Bearer token in the Authorization header.

Authorization: Bearer tl-sk-your-api-key-here

Generate API keys from the dashboard.

Chat Completions

Generate text responses from any of the available AI models.

POST /api/v1/chat/completions

Request Body

{
  "model": "tamgalabs/gpt-5",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is AI?"}
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "top_p": 1,
  "stream": false
}

Parameters

ParameterTypeDefaultDescription
modelstring-Model ID (e.g. tamgalabs/gpt-5)
messagesarray-Array of message objects with role and content
temperaturenumber0.7Sampling temperature (0-2)
max_tokensinteger1024Maximum tokens in response
streambooleanfalseEnable SSE streaming
top_pnumber1Nucleus sampling threshold
stopstring/arraynullStop sequences
toolsarraynullTool definitions for function calling
seedintegernullDeterministic sampling seed

Streaming

Set stream: true for real-time SSE (Server-Sent Events) responses. Each chunk contains a delta of the generated content.

curl https://tamgalabs.tr/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tamgalabs/gpt-5",
    "messages": [{"role": "user", "content": "Tell me a story"}],
    "stream": true
  }'

Stream ends with data: [DONE].

Embeddings

Soon

Generate vector embeddings for text inputs. This endpoint is in development. Join the waitlist to get early access.

Images

Soon

Generate images from text prompts. This endpoint is in development. Join the waitlist to get early access.

Rerank

Soon

Re-rank documents by relevance to a query. This endpoint is in development. Join the waitlist to get early access.

Models & Pricing

250+ AI models available. All models are accessed through the same API endpoint with consistent pricing. View the complete model catalog on the Models page.

GET /api/v1/models

Example pricing: $0.05-$30.00 per 1M input tokens, $0.20-$75.00 per 1M output tokens - depending on model.

Python SDK (OpenAI)

Use the official OpenAI Python library with TamgaLabs as the base URL.

pip install openai
from openai import OpenAI

client = OpenAI(
    base_url="https://tamgalabs.tr/api/v1",
    api_key="YOUR_API_KEY"
)

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

# Streaming
stream = client.chat.completions.create(
    model="tamgalabs/gpt-5",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

# Models list
models = client.models.list()
for m in models:
    print(m.id)

JavaScript / Node.js

const response = await fetch("https://tamgalabs.tr/api/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "tamgalabs/gpt-5",
    messages: [{role: "user", content: "Hello!"}],
    stream: false
  })
});
const data = await response.json();
console.log(data.choices[0].message.content);

cURL Examples

# Chat
curl https://tamgalabs.tr/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tamgalabs/gpt-5",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# List models
curl https://tamgalabs.tr/api/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"

Credits & Billing

TamgaLabs uses a prepaid credit system. Here is how it works:

  • Deposit funds to your account to get started (minimum $5.00)
  • Each API call deducts from your credit balance based on actual token usage x model pricing
  • You can monitor your credit balance in the Billing Dashboard
  • When your balance reaches $0, API requests return 402 Insufficient Credits
  • Credit top-up Coming Soon

Check your balance via API:

curl https://tamgalabs.tr/api/dashboard/billing \
  -H "Cookie: tamgalabs_session=YOUR_SESSION"

Rate Limits

LimitValue
Requests per minute20
Response when exceededHTTP 429 + JSON error

Error Handling

CodeHTTP StatusDescription
invalid_api_key401Bad or expired API key
insufficient_credits402Credit balance is $0
model_not_found404Unknown model ID
rate_limit_exceeded429Too many requests
missing_parameters400Required fields missing