DeepInfra Text Completions API

OpenAI-compatible text completion endpoints.

Operations 1

POST /v1/completions Openai Completions #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/deepinfra:deepinfra-text-completions-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

deepinfra-text-completions-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: DeepInfra Text Completions 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
tags:
- name: Text Completions
  description: OpenAI-compatible text completion endpoints.
paths:
  /v1/completions:
    post:
      tags:
      - Text Completions
      summary: Openai Completions
      operationId: openai_completions_v1_completions_post
      security:
      - HTTPBearer: []
      parameters:
      - name: x-deepinfra-source
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          title: X-Deepinfra-Source
      - name: x-deepinfra-service-tier
        in: header
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Per-request service tier (`priority` or `flex`) for clients that cannot set the `service_tier` body field. The body field wins when both are present; unrecognized values ride the default tier.
          title: X-Deepinfra-Service-Tier
        description: Per-request service tier (`priority` or `flex`) for clients that cannot set the `service_tier` body field. The body field wins when both are present; unrecognized values ride the default tier.
      - 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'
components:
  schemas:
    PromptCacheOptions:
      properties:
        mode:
          anyOf:
          - type: string
            enum:
            - explicit
            - implicit
          - type: 'null'
          title: Mode
          description: Prompt caching mode; 'explicit' requests explicit caching.
        ttl:
          anyOf:
          - type: string
            enum:
            - 5m
            - 1h
          - type: 'null'
          title: Ttl
          description: Requested cache retention for this request's prefix.
      type: object
      title: PromptCacheOptions
    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
    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
    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
    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. For compatibility, 'auto' is treated as 'priority' and 'standard_only' as 'default'.
        fail_fast:
          type: boolean
          title: Fail Fast
          description: If true, the request is rejected immediately with HTTP 429 when the model has no spare capacity, instead of waiting in the queue. Opt-in; the default (false) keeps standard queueing behavior.
          default: false
        models:
          anyOf:
          - items:
              type: string
            type: array
            maxItems: 4
            minItems: 1
          - type: 'null'
          title: Models
          description: 'Ordered list of up to 4 fallback models. The request is attempted on each model in order: when a model rejects it for lack of capacity (HTTP 429 model-busy / flex no-capacity), the next model is tried server-side. The first model that accepts serves the request; the response''s model field and billing reflect that model, at that model''s pricing. Models before the last are attempted without queueing (as if fail_fast were set); the last model honors the request''s own fail_fast value. When models is set, the model field is ignored. Entries must be plain model names (no deploy_id:, custom_hostport, or :revision specifiers); duplicate entries are ignored, keeping the first occurrence.'
        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.0
            exclusiveMinimum: 0.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.0
          minimum: 0.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.0
        top_p:
          type: number
          maximum: 1.0
          exclusiveMinimum: 0.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.0
        min_p:
          type: number
          maximum: 1.0
          minimum: 0.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.0
        top_k:
          type: integer
          exclusiveMaximum: 1000.0
          minimum: 0.0
          title: Top K
          description: Sample from the best k (number of) tokens. 0 means off
          default: 0
        n:
          type: integer
          maximum: 4.0
          minimum: 1.0
          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.0
          minimum: -2.0
          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.0
          minimum: -2.0
          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.0
          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: 1.8446744073709552e+19
            minimum: -9.223372036854776e+18
          - 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.
        prompt_cache_options:
          anyOf:
          - $ref: '#/components/schemas/PromptCacheOptions'
          - type: 'null'
          description: 'Prompt cache options for this request''s prefix, e.g. {"ttl": "1h"}.'
        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,...').
        ignore_eos:
          anyOf:
          - type: boolean
          - type: 'null'
          title: Ignore Eos
          description: Keep generating until max_tokens instead of stopping at the end-of-sequence token. Only honoured on models tagged with the allow_ignore_eos feature flag; ignored otherwise. Intended for benchmarking, where a fixed output length is needed.
      type: object
      required:
      - model
      - prompt
      title: OpenAICompletionsIn
    JsonObjectResponseFormat:
      properties:
        type:
          type: string
          const: json_object
          title: Type
          default: json_object
      type: object
      title: JsonObjectResponseFormat
    TextResponseFormat:
      properties:
        type:
          type: string
          const: text
          title: Type
          default: text
      type: object
      title: TextResponseFormat
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
    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
    ServiceTier:
      type: string
      enum:
      - default
      - priority
      - flex
      title: ServiceTier
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer