Execute raw prompt completions without creating or storing a prompt first. Ideal for developers who want direct API access.
Authentication
Use your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEYAvailable Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/completions | Main endpoint (use ?stream=true/false) |
| POST | /api/completions/sync | Non-streaming response |
| POST | /api/completions/stream | HTTP/2 streaming (JSON array) |
| POST | /api/completions/sse | Server-Sent Events streaming |
Request Body
{
"promptText": "string (required)",
"systemMessage": "string (optional)",
"aiSystem": "string (required)",
"model": "string (required)",
"configuration": { },
"replacements": { },
"dataspaceIds": ["uuid"],
"metadata": { }
}Fields
| Field | Type | Required | Description |
|---|---|---|---|
promptText | string | Yes | The prompt text. Supports {{variable}} placeholders |
systemMessage | string | No | System message for AI context |
aiSystem | string | Yes | AI provider: HyperleapAi (included models), OpenAi or Anthropic (your own key) |
model | string | Yes | Model id (e.g., hl-gpt-6-luna, gpt-6-luna, claude-haiku-5-5). See Available Models |
configuration | object | No | Model parameters (temperature, max_tokens, etc.) |
replacements | object | No | Key-value pairs for {{variable}} substitution |
dataspaceIds | array | No | Dataspace UUIDs for RAG grounding |
metadata | object | No | Custom metadata to attach |
Examples
Basic Request
curl -X POST "https://api.hyperleapai.com/api/completions/sync" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"promptText": "Say hello in French",
"aiSystem": "HyperleapAi",
"model": "hl-gpt-6-luna"
}'With Variable Replacements
curl -X POST "https://api.hyperleapai.com/api/completions/sync" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"promptText": "Translate to {{language}}: {{text}}",
"aiSystem": "HyperleapAi",
"model": "hl-gpt-6-luna",
"replacements": {
"language": "Spanish",
"text": "Hello world"
}
}'With System Message
curl -X POST "https://api.hyperleapai.com/api/completions/sync" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"promptText": "What is the capital of France?",
"systemMessage": "You are a geography expert. Be concise.",
"aiSystem": "HyperleapAi",
"model": "hl-gpt-6-luna"
}'Streaming (SSE)
curl -X POST "https://api.hyperleapai.com/api/completions/sse" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"promptText": "Count from 1 to 5",
"aiSystem": "HyperleapAi",
"model": "hl-gpt-6-luna"
}'With Configuration
curl -X POST "https://api.hyperleapai.com/api/completions/sync" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"promptText": "Write a creative story about a robot",
"aiSystem": "HyperleapAi",
"model": "hl-gpt-6-luna",
"configuration": {
"max_tokens": 500
}
}'Response Format
Sync Response
{
"choices": [{
"finish_reason": "Stop",
"index": 0,
"message": {
"role": "Assistant",
"content": "Bonjour!"
}
}],
"messageId": "uuid",
"runId": "uuid",
"usage": {
"prompt_tokens": 21,
"completion_tokens": 7,
"total_tokens": 28
}
}SSE Response
data: {"choice":{"index":0,"message":{"role":"assistant","content":"Hello"}},...}
data: {"choice":{"index":0,"message":{"role":"assistant","content":" world"}},...}
data: {"choice":{"index":0,"finish_reason":"Stop","message":{"role":"assistant"}},...}Available Models
HyperleapAi
Included on every plan and billed in Hyperleap credits.
hl-gpt-6-luna(default)hl-claude-haiku-5-5
OpenAi
Requires your own OpenAI key, set at the organization level (BYOK).
gpt-6-luna
Anthropic
Requires your own Anthropic key, set at the organization level (BYOK).
claude-opus-5-5claude-sonnet-5-5claude-haiku-5-5
GPT-6 models run at a fixed temperature of 1, and Claude 5.5 models don't use temperature or top_p. The API ignores those parameters for these models.
Error Handling
| Status | Description |
|---|---|
| 400 | Invalid request (missing required fields, invalid model) |
| 401 | Unauthorized (invalid or missing API key) |
| 500 | Server error |
Notes
- Credits are consumed for each API call
- Variable replacement uses Handlebars syntax:
{{variableName}} - All endpoints support the same request body format
- Use
/api/completions?stream=truefor streaming via query parameter
POST /api/completions
POST /api/completions/sync
POST /api/completions/stream
POST /api/completions/sse