Authentication

All API requests require authentication. You must include your unique API key in the Authorization header of your HTTP request.

Authorization: Bearer fl_sk_live_51M...

Note: API keys are secret. Do not share them in client-side code (browsers, mobile apps).

Errors & Rate Limits

The API uses standard HTTP response codes to indicate the success or failure of an API request.

Code Description
200 OK Request successful.
401 Unauthorized Invalid or missing API key.
402 Payment Required Insufficient FLT balance or subscription expired.
429 Too Many Requests Rate limit exceeded (varies by tier).

Chat Completion

The core endpoint for interacting with the Brain. It supports both simple chat interactions and complex "Brain Mode" orchestration.

POST https://forgelab.one/api/v1/chat/completions

Request Body

Parameter Type Required Description
message string Yes The prompt or instruction for the AI.
model string No ID of the model to use (e.g. x-ai/grok-code-fast-1). Defaults to system recommended.
mode string No brain (orchestrator) or chat (direct). Default: brain.
temperature float No Sampling temperature between 0 and 2. Default: 0.7.

Example Request

{
  "message": "Create a React component for a login form",
  "model": "x-ai/grok-code-fast-1",
  "mode": "brain",
  "temperature": 0.5
}

Example Response

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "x-ai/grok-code-fast-1",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Here is the React component code..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 50,
    "completion_tokens": 150,
    "total_tokens": 200,
    "cost_flt": 1250
  }
}

Models

List the currently available models and their pricing categories.

GET https://forgelab.one/api/v1/models

Example Response

{
  "object": "list",
  "data": [
    {
      "id": "x-ai/grok-code-fast-1",
      "object": "model",
      "owned_by": "x-ai",
      "pricing": {
        "input_flt_per_1k": 5,
        "output_flt_per_1k": 15
      }
    },
    {
      "id": "google/gemini-3-flash-preview",
      "object": "model",
      "owned_by": "google"
    }
  ]
}