Langdock fim API

The fim API from Langdock — 1 operation(s) for fim.

OpenAPI Specification

langdock-fim-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  title: Langdock Agent fim API
  version: 3.0.0
servers:
- url: https://api.langdock.com
  description: Production
security:
- bearerAuth: []
tags:
- name: fim
paths:
  /mistral/{region}/v1/fim/completions:
    post:
      summary: Fim Completion
      description: FIM completion.
      parameters:
      - name: region
        in: path
        required: true
        description: The region of the API to use.
        schema:
          type: string
          enum:
          - eu
      operationId: fim_completion_v1_fim_completions_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FIMCompletionRequest'
            example:
              model: codestral-2501
              prompt: 'function removeSpecialCharactersWithRegex(str: string) {'
              max_tokens: 64
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FIMCompletionResponse'
              example:
                data: asd
                id: 245c52bc936f53ba90327800c73d1c3e
                object: chat.completion
                model: codestral
                usage:
                  prompt_tokens: 16
                  completion_tokens: 102
                  total_tokens: 118
                created: 1732902806
                choices:
                - index: 0
                  message:
                    content: "\n  // Use a regular expression to match any non-alphanumeric character and replace it with an empty string\n  return str.replace(/[^a-zA-Z0-9]/g, '');\n}\n\n// Test the function\nconst inputString = \"Hello, World! 123\";\nconst outputString = removeSpecialCharactersWithRegex(inputString);\nconsole.log(outputString); // Output: \"HelloWorld123\""
                    prefix: false
                    role: assistant
                  finish_reason: stop
            text/event-stream:
              schema:
                $ref: '#/components/schemas/CompletionEvent'
      tags:
      - fim
components:
  schemas:
    FIMCompletionRequest:
      properties:
        model:
          anyOf:
          - type: string
          title: Model
          default: codestral-2501
          description: "ID of the model to use. Only compatible for now with:\n  - `codestral-2501`"
        temperature:
          anyOf:
          - type: number
            maximum: 1.5
            minimum: 0
          title: Temperature
          description: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
        top_p:
          type: number
          maximum: 1
          minimum: 0
          title: Top P
          default: 1
          description: Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
        max_tokens:
          anyOf:
          - type: integer
            minimum: 0
          title: Max Tokens
          description: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
        stream:
          type: boolean
          title: Stream
          default: false
          description: 'Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.'
        stop:
          anyOf:
          - type: string
          - items:
              type: string
            type: array
          title: Stop
          description: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
        random_seed:
          anyOf:
          - type: integer
            minimum: 0
          title: Random Seed
          description: The seed to use for random sampling. If set, different calls will generate deterministic results.
        prompt:
          type: string
          title: Prompt
          description: The text/code to complete.
        suffix:
          anyOf:
          - type: string
          title: Suffix
          default: ''
          description: Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`.
        min_tokens:
          anyOf:
          - type: integer
            minimum: 0
          title: Min Tokens
          description: The minimum number of tokens to generate in the completion.
      additionalProperties: false
      type: object
      required:
      - prompt
      - model
      title: FIMCompletionRequest
    ChatCompletionResponse:
      allOf:
      - $ref: '#/components/schemas/ChatCompletionResponseBase'
      - type: object
        title: ChatCompletionResponse
        properties:
          choices:
            type: array
            items:
              $ref: '#/components/schemas/ChatCompletionChoice'
        required:
        - id
        - object
        - data
        - model
        - usage
    ResponseBase:
      type: object
      title: ResponseBase
      properties:
        id:
          type: string
          example: cmpl-e5cc70bb28c444948073e77776eb30ef
        object:
          type: string
          example: chat.completion
        model:
          type: string
          example: mistral-small-latest
        usage:
          $ref: '#/components/schemas/UsageInfo'
    TextChunk:
      properties:
        type:
          type: string
          enum:
          - text
          title: Type
          default: text
        text:
          type: string
          title: Text
      additionalProperties: false
      type: object
      required:
      - text
      title: TextChunk
    ChatCompletionResponseBase:
      allOf:
      - $ref: '#/components/schemas/ResponseBase'
      - type: object
        title: ChatCompletionResponseBase
        properties:
          created:
            type: integer
            example: 1702256327
    AssistantMessage:
      properties:
        content:
          title: Content
          anyOf:
          - type: string
          - items:
              $ref: '#/components/schemas/ContentChunk'
            type: array
        tool_calls:
          anyOf:
          - items:
              $ref: '#/components/schemas/ToolCall'
            type: array
          title: Tool Calls
        prefix:
          type: boolean
          title: Prefix
          default: false
        role:
          type: string
          default: assistant
          title: Role
          enum:
          - assistant
      additionalProperties: false
      type: object
      title: AgentMessage
    CompletionResponseStreamChoice:
      title: CompletionResponseStreamChoice
      type: object
      required:
      - index
      - delta
      - finish_reason
      properties:
        index:
          type: integer
        delta:
          $ref: '#/components/schemas/DeltaMessage'
        finish_reason:
          type: string
          enum:
          - stop
          - length
          - error
          - tool_calls
    DeltaMessage:
      title: DeltaMessage
      type: object
      properties:
        role:
          anyOf:
          - type: string
        content:
          anyOf:
          - type: string
          - items:
              $ref: '#/components/schemas/ContentChunk'
            type: array
        tool_calls:
          anyOf:
          - type: array
            items:
              $ref: '#/components/schemas/ToolCall'
    ChatCompletionChoice:
      title: ChatCompletionChoice
      type: object
      required:
      - index
      - finish_reason
      - message
      properties:
        index:
          type: integer
          example: 0
        message:
          $ref: '#/components/schemas/AssistantMessage'
        finish_reason:
          type: string
          enum:
          - stop
          - length
          - model_length
          - error
          - tool_calls
          example: stop
    ImageURLChunk:
      properties:
        type:
          type: string
          enum:
          - image_url
          title: Type
          default: image_url
        image_url:
          anyOf:
          - $ref: '#/components/schemas/ImageURL'
          - type: string
          title: Image Url
      additionalProperties: false
      type: object
      required:
      - image_url
      title: ImageURLChunk
      description: '{"type":"image_url","image_url":{"url":"data:image/png;base64,iVBORw0'
    FIMCompletionResponse:
      allOf:
      - $ref: '#/components/schemas/ChatCompletionResponse'
      - type: object
        properties:
          model:
            type: string
            example: codestral-latest
    FunctionCall:
      properties:
        name:
          type: string
          title: Name
        arguments:
          title: Arguments
          anyOf:
          - type: object
            additionalProperties: true
          - type: string
      additionalProperties: false
      type: object
      required:
      - name
      - arguments
      title: FunctionCall
    CompletionEvent:
      title: CompletionEvent
      type: object
      required:
      - data
      properties:
        data:
          $ref: '#/components/schemas/CompletionChunk'
    ImageURL:
      properties:
        url:
          type: string
          title: Url
        detail:
          anyOf:
          - type: string
          title: Detail
      additionalProperties: false
      type: object
      required:
      - url
      title: ImageURL
    ContentChunk:
      oneOf:
      - $ref: '#/components/schemas/TextChunk'
      - $ref: '#/components/schemas/ImageURLChunk'
      discriminator:
        propertyName: type
        mapping:
          image_url: '#/components/schemas/ImageURLChunk'
          text: '#/components/schemas/TextChunk'
      title: ContentChunk
    ToolCall:
      properties:
        id:
          type: string
          title: Id
          default: 'null'
        type:
          $ref: '#/components/schemas/ToolTypes'
          default: function
        function:
          $ref: '#/components/schemas/FunctionCall'
      additionalProperties: false
      type: object
      required:
      - function
      title: ToolCall
    ToolTypes:
      type: string
      enum:
      - function
      title: ToolTypes
    CompletionChunk:
      title: CompletionChunk
      type: object
      required:
      - id
      - model
      - choices
      properties:
        id:
          type: string
        object:
          type: string
        created:
          type: integer
        model:
          type: string
        usage:
          $ref: '#/components/schemas/UsageInfo'
        choices:
          type: array
          items:
            $ref: '#/components/schemas/CompletionResponseStreamChoice'
    UsageInfo:
      title: UsageInfo
      type: object
      properties:
        prompt_tokens:
          type: integer
          example: 16
        completion_tokens:
          type: integer
          example: 34
        total_tokens:
          type: integer
          example: 50
      required:
      - prompt_tokens
      - completion_tokens
      - total_tokens
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"