İçeriğe geç
ajan.io

Belgeler menüsü

Bu sayfada

Codestral

Mistral Codestral modeli ile kod üretimi.

Mistral Codestral modeli ile bir kod completion'ı oluşturur.

Başlamadan önce

  • API key: Bir personal API key oluşturun veya workspace admin'inizden Completion API kapsamına sahip bir workspace API anahtarı isteyin.
  • Model availability: Şu anda API için kullanılabilir Mistral modeli yoktur. Güncellemeler için daha sonra tekrar kontrol edin.

Base URL

https://api.ajan.io/mistral/{region}/v1/fim/completions

Dedicated deployments Tüm isteklerde api.ajan.com'u /api/public ile değiştirin.

Parameters

Mistral fill-in-the-middle Completion endpoint parametrelerinin tümü Mistral spesifikasyonuna göre desteklenir.

Rate limits

Varsayılan limitler 500 RPM (dakikada istek) ve 150.000 TPM (dakikada token)'dır.

  • RPM, workspace, model ve API anahtarı başına uygulanır.
  • TPM, bir workspace'te aynı modeli kullanan tüm API anahtarları arasında paylaşılır.
  • Dedicated deployment'larda admin'ler Settings > Workspace > Products > API üzerinden model başına özel limitler yapılandırabilir.

Rate limit'i aşarsanız 429 Too Many Requests yanıtı alırsınız.

Continue AI Code Agent kullanımı

Codestral modeli ile ajan API'sindeki chat completion modellerini birleştirerek açık kaynaklı AI kod ajanı Continue (continue.dev)'i tamamen ajan API üzerinden kullanabilirsiniz.

Continue bir VS Code extension ve JetBrains eklentisi olarak sunulur. Continue'un kullandığı modelleri özelleştirmek için ~/.continue/config.yaml (MacOS / Linux) veya %USERPROFILE%\.continue\config.yaml (Windows) yapılandırma dosyasını düzenleyin. Eski config.json biçimi kullanımdan kaldırılmıştır.

Aşağıda autocomplete için Codestral, sohbet ve düzenlemeler için Claude Sonnet 4.6 ve GPT-5.2 modellerinin tamamının ajan API'den sunulduğu bir Continue kurulum örneği yer alır.

yaml
name: ajan Configuration
version: 1.0.0
schema: v1

models:
  - name: GPT-5.2
    provider: openai
    model: gpt-5.2
    apiBase: https://api.ajan.io/openai/eu/v1
    apiKey: <YOUR_AJAN_API_KEY>
    roles:
      - chat
      - edit

  - name: Claude Sonnet 4.6
    provider: anthropic
    model: claude-sonnet-4-6-default
    apiBase: https://api.ajan.io/anthropic/eu/v1
    apiKey: <YOUR_AJAN_API_KEY>
    roles:
      - chat
      - edit

  - name: Codestral
    provider: mistral
    model: codestral-2501
    apiBase: https://api.ajan.io/mistral/eu/v1
    apiKey: <YOUR_AJAN_API_KEY>
    roles:
      - autocomplete

ajan, API anahtarınızı korumak ve uygulamalarınızın güvenliğini sağlamak için tarayıcı kaynaklı istekleri bilinçli olarak engeller. Daha fazla bilgi için API Key Best Practices kılavuzuna bakın.

OpenAPI

openapi: 3.0.0
info:
  title: ajan API
  version: 3.0.0
servers:
  - url: https://api.ajan.io
    description: Production
security:
  - bearerAuth: []
paths:
  /mistral/{region}/v1/fim/completions:
    post:
      tags:
        - fim
      summary: Fim Completion
      description: FIM completion.
      operationId: fim_completion_v1_fim_completions_post
      parameters:
        - name: region
          in: path
          required: true
          description: The region of the API to use.
          schema:
            type: string
            enum:
              - eu
      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: >2-

                          // Use a regular expression to match any non-alphanumeric character and replace it with an empty string
                          return str.replace(/[^a-zA-Z0-9]/g, '');
                        }

                        // Test the function

                        const inputString = "Hello, World! 123";

                        const outputString =
                        removeSpecialCharactersWithRegex(inputString);

                        console.log(outputString); // Output: "HelloWorld123"
                      prefix: false
                      role: assistant
                    finish_reason: stop
            text/event-stream:
              schema:
                $ref: '#/components/schemas/CompletionEvent'
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:
              - `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
    FIMCompletionResponse:
      allOf:
        - $ref: '#/components/schemas/ChatCompletionResponse'
        - type: object
          properties:
            model:
              type: string
              example: codestral-latest
    CompletionEvent:
      title: CompletionEvent
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/CompletionChunk'
    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
    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'
    ChatCompletionResponseBase:
      allOf:
        - $ref: '#/components/schemas/ResponseBase'
        - type: object
          title: ChatCompletionResponseBase
          properties:
            created:
              type: integer
              example: 1702256327
    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
    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
    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
    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'
    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
    DeltaMessage:
      title: DeltaMessage
      type: object
      properties:
        role:
          anyOf:
            - type: string
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/ContentChunk'
              type: array
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/ToolCall'
              type: array
    ContentChunk:
      oneOf:
        - $ref: '#/components/schemas/TextChunk'
        - $ref: '#/components/schemas/ImageURLChunk'
      discriminator:
        propertyName: type
        mapping:
          image_url:
            $ref: '#/components/schemas/ImageURLChunk'
          text:
            $ref: '#/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
    TextChunk:
      properties:
        type:
          default: text
          enum:
            - text
          title: Type
          type: string
        text:
          type: string
          title: Text
      additionalProperties: false
      type: object
      required:
        - text
      title: TextChunk
    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'
    ToolTypes:
      type: string
      enum:
        - function
      title: ToolTypes
    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
    ImageURL:
      properties:
        url:
          type: string
          title: Url
        detail:
          anyOf:
            - type: string
          title: Detail
      additionalProperties: false
      type: object
      required:
        - url
      title: ImageURL
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"