Ollama Completions API

Generate text completions using the OpenAI-compatible completions endpoint.

Business capability
Artificial Intelligence Management BC-610.60

Operations 1

POST /completions Ollama Create completion #

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/ollama-completions-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

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

ollama-completions-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Ollama OpenAI Compatibility Completions API
  description: Ollama provides compatibility with parts of the OpenAI API, allowing existing applications built for OpenAI to connect to locally-running models through Ollama. Supported endpoints include chat completions, completions, embeddings, models, images, and the Responses API.
  version: 0.1.0
  contact:
    name: Ollama Team
    url: https://ollama.com
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
- url: http://localhost:11434/v1
  description: Local Ollama Server (OpenAI-compatible)
security:
- bearerAuth: []
tags:
- name: Completions
  description: Generate text completions using the OpenAI-compatible completions endpoint.
paths:
  /completions:
    post:
      operationId: createCompletion
      summary: Ollama Create completion
      description: Creates a completion for the provided prompt. Compatible with the OpenAI Completions API format. Supports streaming, JSON mode, and reproducible outputs.
      tags:
      - Completions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionRequest'
      responses:
        '200':
          description: Successful completion response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/CompletionStreamResponse'
        '400':
          description: Bad Request
        '404':
          description: Model not found
components:
  schemas:
    CompletionResponse:
      type: object
      description: Response object from a text completion request.
      properties:
        id:
          type: string
          description: A unique identifier for the completion.
        object:
          type: string
          description: The object type, always text_completion.
          const: text_completion
        created:
          type: integer
          description: Unix timestamp of when the completion was created.
        model:
          type: string
          description: The model used for the completion.
        choices:
          type: array
          description: A list of completion choices.
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of the choice.
              text:
                type: string
                description: The generated text.
              finish_reason:
                type: string
                description: The reason the model stopped generating.
                enum:
                - stop
                - length
        usage:
          $ref: '#/components/schemas/UsageStats'
    CompletionStreamResponse:
      type: object
      description: A streaming text completion chunk.
      properties:
        id:
          type: string
          description: A unique identifier for the completion.
        object:
          type: string
          description: The object type.
        created:
          type: integer
          description: Unix timestamp of creation.
        model:
          type: string
          description: The model used.
        choices:
          type: array
          description: A list of completion chunk choices.
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of the choice.
              text:
                type: string
                description: The text delta.
              finish_reason:
                type:
                - string
                - 'null'
                description: The finish reason, if applicable.
    CompletionRequest:
      type: object
      description: Request body for creating a text completion in OpenAI-compatible format.
      required:
      - model
      - prompt
      properties:
        model:
          type: string
          description: The model to use for completion.
        prompt:
          description: The prompt to generate completions for.
          oneOf:
          - type: string
          - type: array
            items:
              type: string
        temperature:
          type: number
          description: Sampling temperature between 0 and 2.
          minimum: 0.0
          maximum: 2.0
        top_p:
          type: number
          description: Nucleus sampling parameter.
          minimum: 0.0
          maximum: 1.0
        max_tokens:
          type: integer
          description: Maximum number of tokens to generate.
        frequency_penalty:
          type: number
          description: Penalty for token frequency.
          minimum: -2.0
          maximum: 2.0
        presence_penalty:
          type: number
          description: Penalty for token presence.
          minimum: -2.0
          maximum: 2.0
        seed:
          type: integer
          description: Random seed for deterministic generation.
        stop:
          description: Stop sequences for generation.
          oneOf:
          - type: string
          - type: array
            items:
              type: string
        stream:
          type: boolean
          description: Whether to stream back partial progress.
          default: false
        stream_options:
          type: object
          description: Options for streaming responses.
          properties:
            include_usage:
              type: boolean
              description: If true, includes usage info in the stream.
        suffix:
          type: string
          description: The suffix that comes after the completion.
    UsageStats:
      type: object
      description: Token usage statistics for the request.
      properties:
        prompt_tokens:
          type: integer
          description: Number of tokens in the prompt.
        completion_tokens:
          type: integer
          description: Number of tokens in the generated completion.
        total_tokens:
          type: integer
          description: Total number of tokens used in the request.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key authentication. The key is accepted but not validated by Ollama. Use any value such as ollama.
externalDocs:
  description: Ollama OpenAI Compatibility Documentation
  url: https://docs.ollama.com/api/openai-compatibility