Sahara AI Inference API

OpenAI-compatible chat completion inference.

OpenAPI Specification

sahara-ai-inference-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Sahara AI Compute Discovery Inference API
  description: OpenAI-compatible inference and model-discovery API for the Sahara AI Developer Platform. Exposes a routed compute layer that fans requests out across multiple upstream providers (OpenAI, Lepton, Together, and others), plus discovery endpoints for the models and providers available on the network. Faithful transcription of the published API documentation; not a provider-published OpenAPI.
  version: '1.0'
  contact:
    name: Sahara AI Developer Platform
    url: https://docs.saharaai.com/developer-docs-ai-developer-portal/api-documentation
  x-apisjson-generated: true
  x-source: https://docs.saharaai.com/developer-docs-ai-developer-portal/api-documentation.md
servers:
- url: https://app.saharaai.com/developer/api
  description: AI Developer Platform compute API
- url: https://portal.saharalabs.ai/api
  description: Developer Portal (Sahara Labs) compute API
security:
- ApiKeyAuth: []
- BearerAuth: []
tags:
- name: Inference
  description: OpenAI-compatible chat completion inference.
paths:
  /compute/chat/completions:
    post:
      operationId: createChatCompletion
      summary: Create a chat completion
      description: Send an OpenAI-compatible inference request. Compatible with the OpenAI SDK, LangChain, and the OpenAI Agents SDK. Supports streaming responses. The target provider may be selected via the `OpenAI-Organization` header.
      tags:
      - Inference
      parameters:
      - name: OpenAI-Organization
        in: header
        required: false
        description: Select the upstream compute provider to route the request to.
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          description: An OpenAI-format chat completion.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ChatCompletionResponse:
      type: object
      description: OpenAI-format chat completion.
      properties:
        id:
          type: string
        object:
          type: string
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                $ref: '#/components/schemas/ChatMessage'
              finish_reason:
                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
    ChatCompletionRequest:
      type: object
      required:
      - model
      - messages
      properties:
        model:
          type: string
          description: Model identifier to run inference against.
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        stream:
          type: boolean
          description: When true, stream the response as server-sent events.
    ChatMessage:
      type: object
      required:
      - role
      - content
      properties:
        role:
          type: string
          enum:
          - system
          - user
          - assistant
        content:
          type: string
  responses:
    NotFound:
      description: Not found — verify pipeline or model IDs.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: Bad request — check request formatting.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Internal server error — retry or contact support.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key issued from the Developer Portal. Passed in the `x-api-key` header. Never expose your API key in public code or repositories.
    BearerAuth:
      type: http
      scheme: bearer
      description: API key passed as a Bearer token in the Authorization header (OpenAI-compatible clients).