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

# Estimate a model request

> POST /v1/models/{slug}/estimate

What one request to one model would cost, without running it.

<Warning>An estimate is not a reservation. It cannot know how many tokens a model will actually emit, so treat it as an order of magnitude rather than a quote.</Warning>


## OpenAPI

````yaml openapi.json POST /v1/models/{slug}/estimate
openapi: 3.0.0
info:
  title: Infery Gateway
  description: >-
    Infery Inference Gateway — OpenAI-compatible API for LLMs, embeddings,
    images, audio, and video
  version: '1.0'
  contact: {}
servers:
  - url: https://api.infery.ai
    description: Production
  - url: http://localhost:3001
    description: Local
security: []
tags: []
paths:
  /v1/models/{slug}/estimate:
    post:
      tags:
        - Models
      summary: Estimate credits for a model request
      operationId: estimateModelCredits
      parameters:
        - name: slug
          required: true
          in: path
          description: Model slug used in /v1 requests (e.g. gpt-4o)
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EstimateModelDto'
      responses:
        '200':
          description: >-
            Authoritative pre-request credit estimate. Reuses the same pricing
            logic as the credit hold/settle path (1 credit = $0.01).
          content:
            application/json:
              schema:
                type: object
                properties:
                  credits:
                    type: number
                    nullable: true
                    example: 2
                    description: >-
                      Estimated credits this request would cost. null when the
                      model has no active price (unknown — not free).
        '401':
          description: Unauthorized — invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '404':
          description: Model not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    EstimateModelDto:
      type: object
      properties:
        'n':
          type: number
          description: Number of outputs (images/videos). Defaults to 1.
        size:
          type: string
          description: Image size, e.g. "1024x1024" or a provider label ("1K").
        quality:
          type: string
          description: Image quality (DALL-E standard|hd, GPT Image low|medium|high|auto).
        steps:
          type: number
          description: Diffusion steps (per_megapixel FLUX models).
        imageInputCount:
          type: number
          description: >-
            Number of source images (per_image edit mode). 1 for edits, 0 for
            generate.
        characters:
          type: number
          description: TTS character count.
        durationSeconds:
          type: number
          description: Video/STT duration in seconds.
        resolution:
          type: string
          description: Video resolution tier ("720p" | "1080p" | "4k").
        maxOutputTokens:
          type: number
          description: Upper bound of output tokens for text models.
        totalTokens:
          type: number
          description: Total tokens for embedding/rerank models.
    ErrorResponseDto:
      type: object
      properties:
        error:
          description: >-
            The error envelope. Every non-2xx response from this API has this
            shape, so a client can parse failures without branching on the
            endpoint.
          allOf:
            - $ref: '#/components/schemas/ErrorDetailDto'
      required:
        - error
    ErrorDetailDto:
      type: object
      properties:
        message:
          type: string
          example: Model not found
          description: Human-readable error message
        type:
          type: string
          example: invalid_request_error
          description: Error category
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - quota_exceeded
            - rate_limit_error
            - server_error
        code:
          type: string
          example: model_not_found
          nullable: true
          description: >-
            Stable machine-readable error code. Branch on this rather than on
            `message`, which is prose and may be reworded.
        param:
          type: string
          example: model
          nullable: true
          description: >-
            Name of the request parameter that triggered the error. `null` when
            the error is not attributable to one field.
        job_id:
          type: string
          example: job_1hR9xTPZqK4mVLc2nJ7fY5wB
          description: >-
            Handle to work that is ALREADY RUNNING AND ALREADY BILLED, present
            on the few errors that carry one. When it is here, this is not a
            failure to retry — retrying pays twice. Collect the result from `GET
            /v1/images/jobs/{job_id}`, which serves every durable media job
            regardless of modality.


            Two situations produce it. A media generation that outruns the
            gateway's wait answers `504` with `code: "job_timeout"` and keeps
            working. And `POST /v1/audio/speech` answers **500** with `code:
            "artifact_unreadable"` when the speech was generated and settled but
            could not be read back from storage — the audio exists and is paid
            for; only this response failed.


            Declared here rather than per-endpoint because the rule is about the
            FIELD, not the status: if this is present, there is a paid-for
            result to collect. It was undeclared until now, so a client
            generated from this document could not see the one field that
            recovers money already spent.
      required:
        - message
        - type
        - code
        - param
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key in format: Bearer inf_***'

````