Skip to main content
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, OpenAi, Anthropic, GoogleGemini, Groq, Cohere
modelstringYesModel name (e.g., hl-gpt-4o-mini, gpt-4, claude-3-haiku-20240307)
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-4o-mini"
  }'

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-4o-mini",
    "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-4o-mini"
  }'

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-4o-mini"
  }'

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-4o-mini",
    "configuration": {
      "temperature": 0.9,
      "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

  • hl-gpt-4o-mini
  • hl-gpt-4.1-mini

OpenAi

  • gpt-4o
  • gpt-4o-mini
  • gpt-4-turbo
  • gpt-3.5-turbo

Anthropic

  • claude-3-opus-20240229
  • claude-3-sonnet-20240229
  • claude-3-haiku-20240307

Google Gemini

  • gemini-pro
  • gemini-1.5-pro

Groq

  • llama3-70b-8192
  • mixtral-8x7b-32768

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