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

# Openai Completions



## OpenAPI

````yaml https://api.deepinfra.com/openapi.json post /v1/completions
openapi: 3.1.0
info:
  title: DeepInfra API
  description: >-
    The DeepInfra API provides serverless AI inference, custom model
    deployments, and GPU rentals.
  version: 1.0.0
servers:
  - url: https://api.deepinfra.com
security: []
tags:
  - name: Chat Completions
    description: OpenAI and Anthropic-compatible chat completion endpoints for LLMs.
  - name: Text Completions
    description: OpenAI-compatible text completion endpoints.
  - name: Embeddings
    description: Generate text embeddings for search and RAG.
  - name: Image Generation
    description: Generate, edit, and create variations of images.
  - name: Audio
    description: OpenAI-compatible speech synthesis, transcription, and translation.
  - name: Text to Speech
    description: ElevenLabs-compatible TTS endpoints and voice management.
  - name: Inference
    description: Native DeepInfra inference API for models and deployments.
  - name: Dedicated Models
    description: Deploy and manage private model instances with autoscaling.
  - name: GPU Rentals
    description: Rent dedicated GPU containers.
  - name: Models
    description: Browse, search, and manage AI models.
  - name: Files & Batches
    description: File uploads and batch processing.
  - name: LoRA Adapters
    description: Create, manage, and query LoRA adapter models.
  - name: Agents
    description: Manage agent-framework instances (OpenClaw and friends).
  - name: Sandboxes
    description: Create and manage isolated sandbox environments.
  - name: Account
    description: User profile, team management, and rate limits.
  - name: Authentication
    description: API tokens, SSH keys, scoped JWTs, and login flows.
  - name: Billing
    description: Payment methods, usage tracking, and billing.
  - name: Logs & Metrics
    description: Query inference logs, deployment logs, and usage metrics.
  - name: Utilities
    description: Feedback submission and CLI version.
paths:
  /v1/completions:
    post:
      tags:
        - Text Completions
      summary: Openai Completions
      operationId: openai_completions_v1_completions_post
      parameters:
        - name: x-deepinfra-source
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Deepinfra-Source
        - name: xi-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Xi-Api-Key
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAICompletionsIn'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    OpenAICompletionsIn:
      properties:
        service_tier:
          anyOf:
            - $ref: '#/components/schemas/ServiceTier'
            - type: 'null'
          description: >-
            The service tier used for processing the request. 'priority'
            processes the request with higher priority (premium rate); 'flex'
            processes it at lower priority for a discount, served only when
            spare capacity exists and may be retried/timed out under load. Both
            apply only to models that support the respective tier.
        model:
          type: string
          title: Model
          description: model name
          examples:
            - meta-llama/Llama-2-70b-chat-hf
        prompt:
          anyOf:
            - type: string
            - items:
                type: integer
              type: array
          title: Prompt
          description: input prompt - a single string is currently supported
        max_tokens:
          anyOf:
            - type: integer
              maximum: 10000000
              exclusiveMinimum: 0
            - type: 'null'
          title: Max Tokens
          description: >-
            The maximum number of tokens to generate in the completion.


            The total length of input tokens and generated tokens is limited by
            the model's context length.If explicitly set to None it will be the
            model's max context length minus input length or 65536, whichever is
            smaller.
        temperature:
          type: number
          maximum: 2
          minimum: 0
          title: Temperature
          description: >-
            What sampling temperature to use, between 0 and 2. Higher values
            like 0.8 will make the output more random, while lower values like
            0.2 will make it more focused and deterministic
          default: 1
        top_p:
          type: number
          maximum: 1
          exclusiveMinimum: 0
          title: Top P
          description: >-
            An alternative to sampling with temperature, called nucleus
            sampling, where the model considers the results of the tokens with
            top_p probability mass. So 0.1 means only the tokens comprising the
            top 10% probability mass are considered.
          default: 1
        min_p:
          type: number
          maximum: 1
          minimum: 0
          title: Min P
          description: >-
            Float that represents the minimum probability for a token to be
            considered, relative to the probability of the most likely token.
            Must be in [0, 1]. Set to 0 to disable this.
          default: 0
        top_k:
          type: integer
          exclusiveMaximum: 1000
          minimum: 0
          title: Top K
          description: Sample from the best k (number of) tokens. 0 means off
          default: 0
        'n':
          type: integer
          maximum: 4
          minimum: 1
          title: 'N'
          description: number of sequences to return
          default: 1
        stream:
          type: boolean
          title: Stream
          description: whether to stream the output via SSE or return the full response
          default: false
        logprobs:
          anyOf:
            - type: integer
            - type: 'null'
          title: Logprobs
          description: return top tokens and their log-probabilities
        echo:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Echo
          description: return prompt as part of the respons
        stop:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stop
          description: up to 16 sequences where the API will stop generating further tokens
        presence_penalty:
          type: number
          maximum: 2
          minimum: -2
          title: Presence Penalty
          description: >-
            Positive values penalize new tokens based on whether they appear in
            the text so far, increasing the model's likelihood to talk about new
            topics.
          default: 0
        frequency_penalty:
          type: number
          maximum: 2
          minimum: -2
          title: Frequency Penalty
          description: >-
            Positive values penalize new tokens based on how many times they
            appear in the text so far, increasing the model's likelihood to talk
            about new topics.
          default: 0
        response_format:
          anyOf:
            - $ref: '#/components/schemas/TextResponseFormat'
            - $ref: '#/components/schemas/JsonObjectResponseFormat'
            - $ref: '#/components/schemas/JsonSchemaResponseFormat'
            - $ref: '#/components/schemas/RegexResponseFormat'
            - type: 'null'
          title: Response Format
          description: The format of the response. Currently, only json is supported.
        repetition_penalty:
          type: number
          maximum: 5
          minimum: 0.01
          title: Repetition Penalty
          description: >-
            Alternative penalty for repetition, but multiplicative instead of
            additive (> 1 penalize, < 1 encourage)
          default: 1
        user:
          anyOf:
            - type: string
            - type: 'null'
          title: User
          description: >-
            A unique identifier representing your end-user, which can help 
            monitor and detect abuse. Avoid sending us any identifying
            information. We recommend hashing user identifiers.
        seed:
          anyOf:
            - type: integer
              exclusiveMaximum: 18446744073709552000
              minimum: -9223372036854776000
            - type: 'null'
          title: Seed
          description: >-
            Seed for random number generator. If not provided, a random seed is
            used. Determinism is not guaranteed.
        stream_options:
          anyOf:
            - $ref: '#/components/schemas/StreamOptions'
            - type: 'null'
          description: streaming options
        stop_token_ids:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Stop Token Ids
          description: >-
            Up to 16 token IDs where the API will stop generating further
            tokens. Merged with the model's built-in stop tokens. Intended for
            private deployments.
        return_tokens_as_token_ids:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Return Tokens As Token Ids
          description: return tokens as token ids
        prompt_cache_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Prompt Cache Key
          description: >-
            A key to identify prompt cache for reuse across requests. If
            provided, the prompt will be cached and can be reused in subsequent
            requests with the same key.
        data:
          anyOf:
            - $ref: '#/components/schemas/CompletionMultiModalData'
            - type: 'null'
          description: >-
            Optional multi-modal data to pass alongside the prompt. Only
            supported for a small number of non-chat-native vision models.
            Images must be base64 data URIs (e.g. 'data:image/png;base64,...').
      type: object
      required:
        - model
        - prompt
      title: OpenAICompletionsIn
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ServiceTier:
      type: string
      enum:
        - default
        - priority
        - flex
      title: ServiceTier
    TextResponseFormat:
      properties:
        type:
          type: string
          const: text
          title: Type
          default: text
      type: object
      title: TextResponseFormat
    JsonObjectResponseFormat:
      properties:
        type:
          type: string
          const: json_object
          title: Type
          default: json_object
      type: object
      title: JsonObjectResponseFormat
    JsonSchemaResponseFormat:
      properties:
        type:
          type: string
          const: json_schema
          title: Type
          default: json_schema
        json_schema:
          $ref: '#/components/schemas/JsonSchema'
          description: JSON schema for structured output when type is 'json_schema'
      type: object
      required:
        - json_schema
      title: JsonSchemaResponseFormat
    RegexResponseFormat:
      properties:
        type:
          type: string
          const: regex
          title: Type
          default: regex
        regex:
          type: string
          title: Regex
          description: Regex pattern for structured output when type is 'regex'
      type: object
      required:
        - regex
      title: RegexResponseFormat
    StreamOptions:
      properties:
        include_usage:
          type: boolean
          title: Include Usage
          description: whether to include usage data
          default: true
        continuous_usage_stats:
          type: boolean
          title: Continuous Usage Stats
          description: >-
            whether to include usage stats continuously with each streaming
            event
          default: false
      type: object
      title: StreamOptions
    CompletionMultiModalData:
      properties:
        image:
          items:
            type: string
          type: array
          title: Image
          description: >-
            List of images as base64 data URIs (e.g.
            'data:image/png;base64,...'). Each image must correspond to a
            placeholder token in the prompt.
        video:
          items:
            type: string
          type: array
          title: Video
          description: >-
            List of videos as base64 data URIs (e.g.
            'data:video/mp4;base64,...'). Each video must correspond to a
            placeholder token in the prompt.
      type: object
      title: CompletionMultiModalData
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    JsonSchema:
      properties:
        name:
          type: string
          title: Name
          description: Name identifier for the JSON schema
        schema:
          additionalProperties: true
          type: object
          title: Schema
          description: The actual JSON schema definition
      type: object
      required:
        - name
        - schema
      title: JsonSchema
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````