> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zerogpu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat completions (ZeroClick)

> OpenAI-style chat inference authenticated by a ZeroClick HMAC signature instead of an API key.

This is the [Chat completions](/api-reference/chat-completions) endpoint behind **ZeroClick**, ZeroGPU's agent-payment layer. Same request/response bodies and same model routing as `/v1/chat/completions` — only authentication, authorization, and metering differ.

* **Authentication** — no `x-api-key`. A buying agent calls ZeroClick's hosted pay URL; ZeroClick proxies the request and signs the raw request bytes with an HMAC in the `zc-signature` header. A request is authenticated **only** by a valid signature.
* **Authorization** — a ZeroClick allowance check runs before any billable work. It fails *open* on a transient ZeroClick outage (the signature has already verified), but never for a missing or invalid signature.
* **Metering** — actual token usage is settled with ZeroClick and reported via the `zc-usage` response header. Stripe metering is bypassed; ZeroClick is the sole biller.

Response JSON shape depends on the model; handle errors the same way as [API error codes](/docs/production-patterns#handle-status-codes-explicitly).


## OpenAPI

````yaml api-reference/openapi/zeroclick.openapi.json POST /zeroclick/v1/chat/completions
openapi: 3.1.0
info:
  title: ZeroGPU Orchestration API — ZeroClick endpoints
  version: 1.0.0
  description: >
    OpenAPI specification for the ZeroClick-authenticated orchestration
    endpoints

    (`/zeroclick/v1/*`).


    ZeroClick sits in front of the ZeroGPU Orchestration API as the

    agent-payment layer. A buying agent calls ZeroClick's hosted pay URL;

    ZeroClick then proxies the request to these endpoints, signing the raw

    request bytes with an HMAC in the `zc-signature` header. From this API's

    perspective, a request is authenticated **only** by a valid `zc-signature`

    — there is no `x-api-key` on these routes.


    These endpoints mirror the standard `/v1/chat/completions` and

    `/v1/responses` orchestration endpoints (same request/response bodies,

    same model routing), differing only in:
      * **Authentication** — the `zc-signature` HMAC is verified over the raw
        request bytes instead of an API key.
      * **Authorization** — a ZeroClick allowance check runs before any
        billable work. It fails *open* on a transient ZeroClick outage (the
        signature has already verified), but never for a missing/invalid
        signature.
      * **Metering** — actual token usage is reported back to ZeroClick via the
        `zc-usage` response header on success. Stripe metering is intentionally
        bypassed; ZeroClick is the sole biller.
servers:
  - url: https://api.zerogpu.ai
    description: Production
security: []
tags:
  - name: ZeroClick
    description: ZeroClick agent-payment authenticated orchestration endpoints.
paths:
  /zeroclick/v1/chat/completions:
    post:
      tags:
        - ZeroClick
      summary: Create a chat completion (ZeroClick-authenticated)
      description: |
        OpenAI-style Chat Completions endpoint, authenticated by verifying the
        `zc-signature` HMAC over the raw request bytes. The request is routed by
        `model` using model metadata, and the same orchestration as
        `/v1/chat/completions` runs behind it.

        On success, actual token usage is settled with ZeroClick and reported
        via the `zc-usage` response header.
      operationId: zeroclickCreateChatCompletion
      parameters:
        - $ref: '#/components/parameters/ZcRequestId'
        - $ref: '#/components/parameters/ZcAgentId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              summary:
                summary: Summarization request
                value:
                  model: LFM2.5-1.2B-Instruct
                  messages:
                    - role: user
                      content: 'Summarize the following article: ...'
      responses:
        '200':
          description: >-
            OpenAI Chat Completions response. Includes the `zc-usage` header
            settling actual usage with ZeroClick.
          headers:
            zc-usage:
              $ref: '#/components/headers/ZcUsage'
            x-request-id:
              $ref: '#/components/headers/XRequestId'
            x-inference-type:
              $ref: '#/components/headers/XInferenceType'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/ZeroClickUnauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '420':
          $ref: '#/components/responses/ContextLengthExceeded'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ZeroClickSignature: []
components:
  parameters:
    ZcRequestId:
      name: zc-request-id
      in: header
      required: false
      description: >-
        ZeroClick request id, echoed in logs for correlation. Set by ZeroClick
        when it proxies the request.
      schema:
        type: string
        example: zcreq_1
    ZcAgentId:
      name: zc-agent-id
      in: header
      required: false
      description: >-
        Identifier of the buying agent. Used to partition logs/analytics by
        agent; becomes the synthesized caller identity.
      schema:
        type: string
        example: agt_1
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      additionalProperties: true
      properties:
        model:
          type: string
          description: >-
            Model id; routes the request via model metadata. Kebab-cased into a
            ZeroClick service slug for metering.
          example: LFM2.5-1.2B-Instruct
        messages:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ChatMessage'
        categories:
          type: array
          description: >-
            Candidate labels for text-classification models. May also be
            supplied via a system-role message.
          items:
            type: string
        multilingual:
          type: boolean
          description: >-
            Forwarded to the IAB cloud inference API only when the resolved
            model supports it.
        metadata:
          type: object
          description: |
            Task-specific options. For GLiNER models this carries `usecase`,
            `schema`, `labels`, `threshold`, `mask`, and `replacement_char`. For
            moderation, `threshold`; for signal-extract, `max_keywords`.
          additionalProperties: true
    ChatCompletionResponse:
      type: object
      description: >-
        OpenAI Chat Completions response. For classification models,
        `choices[0].message.content` is a JSON-stringified classification
        result.
      properties:
        id:
          type: string
        object:
          type: string
          const: chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              finish_reason:
                type: string
              message:
                type: object
                properties:
                  role:
                    type: string
                    const: assistant
                  content:
                    type: string
                  annotations:
                    type: array
                    items: {}
        usage:
          $ref: '#/components/schemas/ChatUsage'
      additionalProperties: true
    ChatMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          description: >-
            A `developer` role is normalized to `system`; unrecognized roles are
            treated as `user`.
          enum:
            - system
            - user
            - assistant
            - tool
            - developer
        content:
          type: string
    ChatUsage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          additionalProperties: true
        completion_tokens_details:
          type: object
          additionalProperties: true
    ErrorEnvelope:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
            code:
              type: string
    ZeroClickSignatureError:
      type: object
      required:
        - error
      description: >-
        Returned when the `zc-signature` is missing/invalid or ZeroClick is
        unconfigured.
      properties:
        error:
          type: string
          const: invalid_zeroclick_signature
    PaymentRequiredError:
      type: object
      description: >-
        ZeroClick `payment_required` denial body, produced by the
        `@zeroclickai/sellers` SDK.
      additionalProperties: true
  headers:
    ZcUsage:
      description: |
        Usage report settled with ZeroClick, present on `200` responses. Encodes
        the actual `input_tokens` and `output_tokens` metered against the
        request's ZeroClick service slug.
      schema:
        type: string
    XRequestId:
      description: Correlation id for this request, present on every response.
      schema:
        type: string
    XInferenceType:
      description: >-
        Where inference executed (e.g. `cloud` or an on-device route). Absent
        when inference ran neither on the edge nor in the cloud.
      schema:
        type: string
  responses:
    BadRequest:
      description: >-
        Invalid request — malformed JSON, or a missing/invalid required field
        such as `model` or `messages`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            invalidJson:
              value:
                error:
                  message: Invalid JSON body
                  type: invalid_request_error
            missingModel:
              value:
                error:
                  message: model is required
                  type: invalid_request_error
                  param: model
    ZeroClickUnauthorized:
      description: >
        The `zc-signature` was missing or invalid, or ZeroClick is not
        configured

        for this environment. Unsigned/unverifiable traffic is treated as

        unauthenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ZeroClickSignatureError'
          example:
            error: invalid_zeroclick_signature
    PaymentRequired:
      description: |
        The ZeroClick allowance check denied the request (e.g. insufficient
        allowance or a stale signature timestamp). Body follows ZeroClick's
        `payment_required` schema as returned by the SDK.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PaymentRequiredError'
    ContextLengthExceeded:
      description: >-
        Input token count exceeds the resolved model's `max_tokens` and the
        model is configured to error rather than truncate.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            error:
              message: 'Input exceeds max_tokens (4096) for model: LFM2.5-1.2B-Instruct'
              type: invalid_request_error
              param: messages
              code: context_length_exceeded
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            error:
              message: Internal error
              type: internal_error
  securitySchemes:
    ZeroClickSignature:
      type: apiKey
      in: header
      name: zc-signature
      description: |
        HMAC signature minted by ZeroClick over the raw request bytes, of the
        form `t=<unix-seconds>,kid=<key-id>,v1=<hex-hmac>`. Verified by the
        `@zeroclickai/sellers` SDK against the seller's signing secret keyed by
        `kid`. A missing or invalid signature is rejected with `401`
        `invalid_zeroclick_signature`; this is never failed open.

````