FIM Completion

Fill-in-the-middle completion allows you to complete code by providing a prefix and suffix, with the model generating the middle part.

POST /v1/fim/completions

Request Body

Les paramètres suivants peuvent être inclus dans le corps de la requête :

Paramètres

model
string
Required
Default Value: alphaedge-codex-2-2512

ID of the model with FIM to use.

prompt
string
Required

The prefix code to complete.

suffix
string
Required

The suffix code that should appear after the completion.

max_tokens
integer null

The maximum number of tokens to generate in the completion.

min_tokens
integer null

The minimum number of tokens to generate in the completion.

stop
string array<string>

Up to 4 sequences where the API will stop generating further tokens.

stream
boolean
Default Value: false

Whether to stream back partial progress.

random_seed
integer null

The seed to use for random sampling.

metadata
map<any> null

Metadata to attach to the completion.

Successful Response

Les champs suivants sont retournés dans une réponse réussie :

Champs de réponse

id
string
Required

A unique identifier for the completion.

object
string
Required

The object type, which is always "fim.completion".

model
string
Required

The model used for the completion.

created
integer
Required

The Unix timestamp of when the completion was created.

choices
array<Choice>
Required

The list of completion choices.

usage
UsageInfo
Required

Usage statistics for the completion request.

Examples

Exemples de code pour utiliser cet endpoint :

typescript
import { AlphaEdge } from '@alphaedge/alphaedge';

const alphaedge = new AlphaEdge({
  apiKey: process.env.ALPHAEDGE_API_KEY,
});

const completion = await alphaedge.fim.complete({
  model: 'alphaedge-codex-2-2512',
  prompt: 'def fibonacci(n):',
  suffix: 'return result',
  max_tokens: 100,
});
python
from alphaedge import AlphaEdge

alphaedge = AlphaEdge(api_key="your-api-key")

completion = alphaedge.fim.complete(
    model="alphaedge-codex-2-2512",
    prompt="def fibonacci(n):",
    suffix="return result",
    max_tokens=100
)
curl
curl https://api.alphaedge-ai.com/v1/fim/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ALPHAEDGE_API_KEY" \
  -d '{
    "model": "alphaedge-codex-2-2512",
    "prompt": "def fibonacci(n):",
    "suffix": "return result",
    "max_tokens": 100
  }' 

Response

Exemple de réponse de l'API :

json
{
  "id": "fim-abc123",
  "object": "fim.completion",
  "model": "alphaedge-codex-2-2512",
  "created": 1234567890,
  "choices": [
    {
      "index": 0,
      "content": "    if n <= 1:\n        return n\n    result = fibonacci(n-1) + fibonacci(n-2)\n    ",
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 15,
    "total_tokens": 25
  }
}