Targon Completions API

OpenAI-compatible legacy text completions.

OpenAPI Specification

targon-completions-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Targon Chat Completions API
  description: 'OpenAI-compatible REST API for Targon, the decentralized AI inference platform operated as Bittensor Subnet 4 by Manifold Labs. Inference is produced by a marketplace of miners running OpenAI-compliant endpoints and verified by validators. The public surface follows the OpenAI API shape: chat completions, legacy text completions, model listing, image generation, and search. All requests are authenticated with a Bearer API key.'
  termsOfService: https://targon.com
  contact:
    name: Targon Support
    url: https://docs.targon.com
  version: '1.0'
servers:
- url: https://api.targon.com/v1
  description: Targon OpenAI-compatible inference base URL.
security:
- bearerAuth: []
tags:
- name: Completions
  description: OpenAI-compatible legacy text completions.
paths:
  /completions:
    post:
      operationId: createCompletion
      tags:
      - Completions
      summary: Create a completion
      description: 'Generates a text completion for the provided prompt. Compatible with the OpenAI legacy Completions API. Set `stream: true` to receive the response as Server-Sent Events.'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCompletionRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCompletionResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    CreateCompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: 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
        usage:
          $ref: '#/components/schemas/Usage'
    CreateCompletionRequest:
      type: object
      required:
      - model
      - prompt
      properties:
        model:
          type: string
          description: The id of the model to use.
        prompt:
          oneOf:
          - type: string
          - type: array
            items:
              type: string
          description: The prompt to complete.
        stream:
          type: boolean
          default: false
        temperature:
          type: number
          format: float
          default: 1
        max_tokens:
          type: integer
        top_p:
          type: number
          format: float
          default: 1
        stop:
          oneOf:
          - type: string
          - type: array
            items:
              type: string
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Targon API key passed as a Bearer token in the Authorization header: `Authorization: Bearer $TARGON_API_KEY`.'