Fill-in-the-middle completion allows you to complete code by providing a prefix and suffix, with the model generating the middle part.
/v1/fim/completions
Request Body
Les paramètres suivants peuvent être inclus dans le corps de la requête :
Paramètres
model
alphaedge-codex-2-2512
ID of the model with FIM to use.
prompt
The prefix code to complete.
suffix
The suffix code that should appear after the completion.
max_tokens
The maximum number of tokens to generate in the completion.
min_tokens
The minimum number of tokens to generate in the completion.
stop
Up to 4 sequences where the API will stop generating further tokens.
stream
false
Whether to stream back partial progress.
random_seed
The seed to use for random sampling.
metadata
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
A unique identifier for the completion.
object
The object type, which is always "fim.completion".
model
The model used for the completion.
created
The Unix timestamp of when the completion was created.
choices
The list of completion choices.
usage
Usage statistics for the completion request.
Examples
Exemples de code pour utiliser cet endpoint :
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,
});
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 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 :
{
"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
}
}