Chat Completions

POST

The primary endpoint for all AI interactions. 100% compatible with the OpenAI Chat Completions API schema.

POST /v1/chat/completions

Request Body

FieldTypeRequiredDescription
modelstringREQUIREDUse "auto-route" for intelligent routing, or specify a provider directly (e.g., "claude-3.5-sonnet").
messagesarrayREQUIREDStandard OpenAI message array with role/content pairs.
temperaturenumberoptionalSampling temperature (0–2). Lower = more deterministic.
max_tokensintegeroptionalMaximum tokens in the completion response.
strategystringoptionalRouting strategy override. See Routing Strategies page for options.
streambooleanoptionalEnable Server-Sent Events streaming (default: false).

Example Request

POST /v1/chat/completions
{
  "model": "auto-route",
  "messages": [
    { "role": "system", "content": "You are a Web3 security auditor." },
    { "role": "user", "content": "Audit this Solidity contract for reentrancy..." }
  ],
  "temperature": 0.2,
  "max_tokens": 4096,
  "strategy": "cost-latency-balanced"
}

Example Response

The response follows the standard OpenAI schema with an additional router_telemetry object unique to Meida.

200 OK
{
  "id": "meida-chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1723056000,
  "model": "claude-3.5-sonnet",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I've identified 2 critical vulnerabilities..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 842,
    "completion_tokens": 1205,
    "total_tokens": 2047
  },
  "router_telemetry": {
    "selected_tier": "T4_PREMIUM",
    "selected_provider": "anthropic/claude-3.5-sonnet",
    "classification_ms": 3.8,
    "arbitrage_ms": 7.2,
    "total_routing_ms": 11.0,
    "cost_saved_vs_default": "68%",
    "fallback_triggered": false
  }
}

Router Telemetry Fields

The router_telemetry object is appended to every response and provides full transparency into routing decisions.

selected_tier

The tier level chosen by the arbitrage engine (T1–T4).

selected_provider

The exact provider/model combination that served the request.

classification_ms

Time spent on semantic classification (typically <4ms).

arbitrage_ms

Time spent on tier selection and cost comparison.

total_routing_ms

Total overhead added by the Meida routing pipeline.

cost_saved_vs_default

Percentage cost savings vs. always routing to the most expensive model.

fallback_triggered

Whether a failover reroute occurred during this request.