Mistral AI FIM API

Fill-in-the-Middle code completion operations

Documentation

Specifications

Other Resources

OpenAPI Specification

mistral-fim-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Mistral AI Agents FIM API
  description: Agent completions API for building AI agents that can handle complex tasks, maintain context, coordinate multiple actions, and use tools including function calling. Agents are created and configured via the Mistral platform and invoked through this API.
  version: '1.0'
  contact:
    name: Mistral AI Support
    url: https://docs.mistral.ai/
    email: support@mistral.ai
  termsOfService: https://mistral.ai/terms/
servers:
- url: https://api.mistral.ai/v1
  description: Mistral AI Production
security:
- bearerAuth: []
tags:
- name: FIM
  description: Fill-in-the-Middle code completion operations
paths:
  /fim/completions:
    post:
      operationId: createFimCompletion
      summary: Mistral AI Create a FIM completion
      description: Generate code to fill in between a given prompt prefix and optional suffix. Powered by Codestral for high-quality code completions across 80+ programming languages.
      tags:
      - FIM
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FimCompletionRequest'
      responses:
        '200':
          description: FIM completion response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FimCompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/FimCompletionStreamResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '429':
          description: Rate limit exceeded
components:
  schemas:
    FimCompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
          - chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                type: object
                properties:
                  role:
                    type: string
                  content:
                    type: string
              finish_reason:
                type: string
                enum:
                - stop
                - length
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
    FimCompletionStreamResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
          - chat.completion.chunk
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              delta:
                type: object
                properties:
                  role:
                    type: string
                  content:
                    type: string
              finish_reason:
                type:
                - string
                - 'null'
    FimCompletionRequest:
      type: object
      required:
      - model
      - prompt
      properties:
        model:
          type: string
          description: ID of the model to use
          examples:
          - codestral-latest
        prompt:
          type: string
          description: The text before the code to complete (prefix)
        suffix:
          type: string
          description: The text after the code to complete (optional suffix)
        temperature:
          type: number
          minimum: 0
          maximum: 2
          default: 0.7
          description: Sampling temperature
        top_p:
          type: number
          minimum: 0
          maximum: 1
          default: 1
          description: Nucleus sampling parameter
        max_tokens:
          type: integer
          minimum: 1
          description: Maximum number of tokens to generate
        stream:
          type: boolean
          default: false
          description: Whether to stream partial completions
        stop:
          oneOf:
          - type: string
          - type: array
            items:
              type: string
          description: Stop sequences
        random_seed:
          type: integer
          description: Random seed for deterministic generation
        min_tokens:
          type: integer
          minimum: 0
          description: Minimum number of tokens to generate
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Mistral AI API key passed as a Bearer token
externalDocs:
  description: Mistral AI Agents API Documentation
  url: https://docs.mistral.ai/api/endpoint/agents