Skip to main content

API Reference

Base URL:\

https://app.llmgrid.ai/api/v1

Authentication

Use Authorization: Bearer <token> (Project or Personal token). Most requests include:
  • tenant_id: Your tenant (organization) ID
  • project_id: The project within the tenant

Common Errors

  • 401 Unauthorized — invalid/expired token
  • 403 Forbidden — insufficient role or policy violation
  • 429 Too Many Requests — rate limit/budget exceeded
  • 5xx — upstream provider errors or transient gateway issues

POST /chat/completions

Unified chat API across providers.

Request

{
  "tenant_id": "TENANT_123",
  "project_id": "PROJ_abc",
  "route": "chat_default",
  "messages": [
    {"role": "system", "content": "You are helpful."},
    {"role": "user", "content": "Explain regenerative agriculture in 3 bullets."}
  ],
  "stream": false,
  "temperature": 0.7,
  "top_p": 0.9,
  "max_tokens": 512,
  "metadata": {"requestId": "req-001"}
}

Response

{
  "id": "cmpl_123",
  "route": "chat_default",
  "model": "openai:gpt-4o-mini",
  "object": "chat.completion",
  "created": 1736200000,
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {"prompt_tokens": 120, "completion_tokens": 210, "total_tokens": 330},
  "x_llmgrid_trace_id": "trace_abc123"
}