Completions API

Completions API: execute raw prompt completions in Hyperleap AI without creating or storing a prompt first, with sync or SSE responses and model selection.

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_KEY

Available Endpoints

MethodEndpointDescription
POST/api/completionsMain endpoint (use ?stream=true/false)
POST/api/completions/syncNon-streaming response
POST/api/completions/streamHTTP/2 streaming (JSON array)
POST/api/completions/sseServer-Sent Events streaming

Request Body

{
  "promptText": "string (required)",
  "systemMessage": "string (optional)",
  "aiSystem": "string (required)",
  "model": "string (required)",
  "configuration": { },
  "replacements": { },
  "dataspaceIds": ["uuid"],
  "metadata": { }
}

Fields

FieldTypeRequiredDescription
promptTextstringYesThe prompt text. Supports {{variable}} placeholders
systemMessagestringNoSystem message for AI context
aiSystemstringYesAI provider: HyperleapAi (included models), OpenAi or Anthropic (your own key)
modelstringYesModel id (e.g., hl-gpt-6-luna, gpt-6-luna, claude-haiku-5-5). See Available Models
configurationobjectNoModel parameters (temperature, max_tokens, etc.)
replacementsobjectNoKey-value pairs for {{variable}} substitution
dataspaceIdsarrayNoDataspace UUIDs for RAG grounding
metadataobjectNoCustom 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-5
  • claude-sonnet-5-5
  • claude-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

StatusDescription
400Invalid request (missing required fields, invalid model)
401Unauthorized (invalid or missing API key)
500Server 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=true for streaming via query parameter
POST /api/completions
POST /api/completions/sync
POST /api/completions/stream
POST /api/completions/sse

Explore Hyperleap AI

An AI front desk that answers customer questions, collects contact details, and books appointments on your website and messaging channels.