Create Completion

Creates a completion for the provided prompt and parameters.

POST /v1/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-large-3-2512

ID of the model to use.

prompt
string array<string>
Required

The prompt(s) to generate completions for.

max_tokens
integer null

The maximum number of tokens to generate.

temperature
number
Default Value: 1.0

What sampling temperature to use, between 0 and 2.

stream
boolean
Default Value: false

Whether to stream back partial progress.

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 "text_completion".

created
integer
Required

The Unix timestamp of when the completion was created.

model
string
Required

The model used for the completion.

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.completions.create({
  model: 'alphaedge-large-3-2512',
  prompt: 'Say hello!',
  max_tokens: 50
});
python
from alphaedge import AlphaEdge

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

completion = alphaedge.completions.create(
    model="alphaedge-large-3-2512",
    prompt="Say hello!",
    max_tokens=50
)
curl
curl https://api.alphaedge-ai.com/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ALPHAEDGE_API_KEY" \
  -d '{
    "model": "alphaedge-large-3-2512",
    "prompt": "Say hello!",
    "max_tokens": 50
  }' 

Response

Exemple de réponse de l'API :

json
{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1234567890,
  "model": "alphaedge-large-3-2512",
  "choices": [
    {
      "text": "Hello! How can I help you?",
      "index": 0,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 2,
    "completion_tokens": 7,
    "total_tokens": 9
  }
}