---
title: "Llm Messages"
method: POST
path: "/v7/llm/messages"
tags: ["v7_llm"]
---

# Llm Messages

`POST /v7/llm/messages`

Llm Messages. OpenAI- and Anthropic-compatible LLM endpoint on /v7/llm/messages. Authenticate with `Authorization: Bearer <key>`, `x-api-key`, or the `key` header. Discover model ids with GET /v7/llm/v1/models. Failures arrive on HTTP 200 with `status: "error"`.

## Request body

- object
  - `key` string — API key. Optional when the key is sent as a header.

## Response `200`

OpenAI-compatible chat completion. Errors also arrive on 200 with `status: "error"`.

- union — OpenAI-compatible chat completion, or the shared error envelope. Streaming requests (`stream: true`) return text/event-stream instead of this object.
  - LlmChatCompletion
    - `id` string, required
    - `object` string
    - `created` integer — Unix timestamp.
    - `model` string
    - `choices` object[], required
      - `index` integer
      - `finish_reason` string, nullable
      - `message` object
        - `role` string
        - `content` string, nullable
    - `usage` object
      - `prompt_tokens` integer
      - `completion_tokens` integer
      - `total_tokens` integer
  - GenerationError — Failure envelope. Note that generation endpoints return this on HTTP 200 — branch on `status` and `code`, not on the HTTP status.
    - `status` 'error', required
    - `code` 'validation_error' | 'invalid_api_key' | 'unauthenticated' | 'forbidden' | 'no_subscription' | 'insufficient_balance' | 'not_found' | 'rate_limited' | 'provider_error' | 'upstream_unavailable' | 'server_error' — Stable machine-readable error code. Branch on this.
    - `message` string, required — Human-readable explanation. Wording is not stable; do not parse it.
    - `errors` object — Per-field validation detail. Present when code is "validation_error".
    - `tips` string — Optional remediation hint.

## Other responses

- `400` — Malformed request. Rejected at the edge before reaching the API.
- `401` — Missing or invalid API key.
- `403` — No active subscription for this endpoint.
- `404` — Endpoint, model or request id not found.
- `422` — Validation error.
- `429` — Rate limited at the edge. The API itself signals rate limiting on 200 with code "rate_limited".
- `500` — Server error.

---

[API](https://skmtc.dev/modelslab/apis/modelslab-generation-api.md) · [All operations](https://skmtc.dev/modelslab/apis/modelslab-generation-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/modelslab/modelslab-generation-api/revisions/49cdc29cc724/schema)
