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

# Create a completion

> Continues a raw text prompt with no chat template applied. Compatible with OpenAI's legacy Completions API. Use chat completions unless you build the prompt format yourself.



## OpenAPI

````yaml /openapi.yaml post /completions
openapi: 3.1.0
info:
  title: fastrun API
  version: '1.0'
  description: >-
    OpenAI-compatible inference API. Point any OpenAI SDK at
    https://api.fastrun.si/v1 and send a fastrun API key as a bearer token.
servers:
  - url: https://api.fastrun.si/v1
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Conversations with chat messages.
  - name: Completions
    description: Raw text continuation.
  - name: Models
    description: The models you can use.
paths:
  /completions:
    post:
      tags:
        - Completions
      summary: Create a completion
      description: >-
        Continues a raw text prompt with no chat template applied. Compatible
        with OpenAI's legacy Completions API. Use chat completions unless you
        build the prompt format yourself.
      operationId: createCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionRequest'
            example:
              model: google/gemma-4-31b-it
              prompt: The three primary colors are
              max_tokens: 32
      responses:
        '200':
          description: >-
            The completion. With `stream: true` the body is a
            `text/event-stream` of completion events ending with `data: [DONE]`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Completion'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '502':
          $ref: '#/components/responses/BadGateway'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  schemas:
    CompletionRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          examples:
            - google/gemma-4-31b-it
        prompt:
          description: The text to continue.
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        stream:
          type: boolean
          default: false
        stream_options:
          type: object
          properties:
            include_usage:
              type: boolean
              default: false
        max_tokens:
          type: integer
          minimum: 1
          maximum: 16384
          default: 16
          description: Maximum number of tokens to generate.
        temperature:
          type: number
          minimum: 0
          maximum: 2
        top_p:
          type: number
          minimum: 0
          maximum: 1
        top_k:
          type: integer
          minimum: 0
          maximum: 1000
        stop:
          oneOf:
            - type: string
            - type: array
              maxItems: 4
              items:
                type: string
        seed:
          type: integer
        logprobs:
          type: integer
          minimum: 0
          maximum: 20
          description: >-
            Return the log probabilities of this many most likely tokens at each
            position.
    Completion:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - text_completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              text:
                type: string
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
        usage:
          $ref: '#/components/schemas/Usage'
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
          description: Input tokens, including cached ones.
        completion_tokens:
          type: integer
          description: Generated tokens, including reasoning tokens.
        total_tokens:
          type: integer
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              description: >-
                Input tokens served from the prompt cache. See [Prompt
                caching](/guides/prompt-caching).
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
            - code
          properties:
            message:
              type: string
              description: What went wrong, for people.
            type:
              type: string
              description: Error category, for code.
              enum:
                - invalid_request_error
                - authentication_error
                - rate_limit_error
                - upstream_error
                - unavailable
            code:
              type: integer
              description: The HTTP status.
  responses:
    BadRequest:
      description: >-
        The request is malformed: the body is not a JSON object, `model` is
        missing, or the model rejected a parameter (for example, a prompt longer
        than the context window).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: model is required
              type: invalid_request_error
              code: 400
    Unauthorized:
      description: >-
        The API key is missing, unknown or revoked, or the account has not been
        approved yet.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: invalid or missing API key
              type: authentication_error
              code: 401
    TooManyRequests:
      description: >-
        Every GPU serving the model is busy. Retry after the number of seconds
        in `Retry-After`.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: all backends for this model are at capacity
              type: rate_limit_error
              code: 429
    BadGateway:
      description: The GPU servers failed to answer. Safe to retry.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: all backends refused the request
              type: upstream_error
              code: 502
    Unavailable:
      description: >-
        Temporarily unavailable: no GPU server for the model is up, or API keys
        cannot be checked right now. Retry after the number of seconds in
        `Retry-After`.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: no backend is available for this model
              type: unavailable
              code: 503
  headers:
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
        minimum: 1
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A key from https://fastrun.si/dashboard/keys (starts with `fr_`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.