Zum Hauptinhalt springen
POST
/
mistral
/
{region}
/
v1
/
fim
/
completions
Fim Completion
curl --request POST \
  --url https://api.langdock.com/mistral/{region}/v1/fim/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "codestral-2501",
  "prompt": "function removeSpecialCharactersWithRegex(str: string) {",
  "max_tokens": 64
}
'
{
  "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
  "object": "chat.completion",
  "model": "codestral-latest",
  "usage": {
    "prompt_tokens": 16,
    "completion_tokens": 34,
    "total_tokens": 50
  },
  "created": 1702256327,
  "choices": [
    {
      "index": 0,
      "message": {
        "content": "<string>",
        "tool_calls": [
          {
            "function": {
              "name": "<string>",
              "arguments": {}
            },
            "id": "null",
            "type": "function"
          }
        ],
        "prefix": false,
        "role": "assistant"
      },
      "finish_reason": "stop"
    }
  ]
}
Erstellt eine Code-Vervollständigung mit dem Codestral-Modell von Mistral. Alle Parameter des Mistral Fill-in-the-Middle Completion Endpunkts werden gemäß den Mistral-Spezifikationen unterstützt.

Rate Limits

Die Rate Limit für den FIM Completion Endpunkt beträgt 500 RPM (Anfragen pro Minute) und 60.000 TPM (Token pro Minute). Rate Limits werden auf Workspace-Ebene definiert - und nicht auf API-Schlüssel-Ebene. Jedes Modell hat seine eigene Rate Limit. Wenn du deine Rate Limit überschreitest, erhältst du eine 429 Too Many Requests Antwort. Bitte beachte, dass die Rate Limits Änderungen unterliegen. Beziehe dich auf diese Dokumentation für die aktuellsten Informationen. Falls du eine höhere Rate Limit benötigst, kontaktiere uns bitte unter [email protected].

Verwendung des Continue AI Code Agents

Die Verwendung des Codestral-Modells in Kombination mit Chat-Completion-Modellen der Langdock API ermöglicht es, den Open-Source-KI-Code-Agenten Continue (continue.dev) vollständig über die Langdock API zu nutzen. Continue ist als VS Code-Erweiterung und als JetBrains-Erweiterung verfügbar. Um die von Continue verwendeten Modelle anzupassen, kannst du die Konfigurationsdatei unter ~/.continue/config.json (MacOS / Linux) oder %USERPROFILE%\.continue\config.json (Windows) bearbeiten. Nachfolgend findest du ein Beispiel-Setup für die Verwendung von Continue mit dem Codestral-Modell für Autovervollständigung und Claude 3.5 Sonnet und GPT-4o-Modellen für Chats und Bearbeitungen, die alle über die Langdock API bereitgestellt werden.
{
  "models": [
    {
      "title": "GPT-4o",
      "provider": "openai",
      "model": "gpt-4o",
      "apiKey": "<YOUR_LANGDOCK_API_KEY>",
      "apiBase": "https://api.langdock.com/openai/eu/v1"
    },
    {
      "title": "Claude 3.5 Sonnet",
      "provider": "anthropic",
      "model": "claude-3-5-sonnet-20240620",
      "apiKey": "<YOUR_LANGDOCK_API_KEY>",
      "apiBase": "https://api.langdock.com/anthropic/eu/v1"
    }
  ],
  "tabAutocompleteModel": {
    "title": "Codestral",
    "provider": "mistral",
    "model": "codestral-2501",
    "apiKey": "<YOUR_LANGDOCK_API_KEY>",
    "apiBase": "https://api.langdock.com/mistral/eu/v1"
  }
  /* ... other configuration ... */
}
Langdock blockiert bewusst Browser-basierte Anfragen, um deinen API-Schlüssel zu schützen und die Sicherheit deiner Anwendungen zu gewährleisten. Weitere Informationen findest du in unserem Guide zu Best Practices für API-Schlüssel.

Autorisierungen

Authorization
string
header
erforderlich

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Header

Authorization
string
erforderlich

API key as Bearer token. Format "Bearer YOUR_API_KEY"

Pfadparameter

region
enum<string>
erforderlich

The region of the API to use.

Verfügbare Optionen:
eu

Body

application/json
model
string
Standard:codestral-2501
erforderlich

ID of the model to use. Only compatible for now with:

  • codestral-2501
prompt
string
erforderlich

The text/code to complete.

temperature
number

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.

Erforderlicher Bereich: 0 <= x <= 1.5
top_p
number
Standard:1

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.

Erforderlicher Bereich: 0 <= x <= 1
max_tokens
integer

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.

Erforderlicher Bereich: x >= 0
stream
boolean
Standard:false

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

Stop generation if this token is detected. Or if one of these tokens is detected when providing an array

random_seed
integer

The seed to use for random sampling. If set, different calls will generate deterministic results.

Erforderlicher Bereich: x >= 0
suffix
string
Standard:""

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
integer

The minimum number of tokens to generate in the completion.

Erforderlicher Bereich: x >= 0

Antwort

Successful Response

id
string
erforderlich
Beispiel:

"cmpl-e5cc70bb28c444948073e77776eb30ef"

object
string
erforderlich
Beispiel:

"chat.completion"

model
string
erforderlich
Beispiel:

"codestral-latest"

usage
UsageInfo · object
erforderlich
created
integer
Beispiel:

1702256327

choices
ChatCompletionChoice · object[]