Skip to main content
POST
https://llm.ai-nebula.com
/
v1
/
chat
/
completions
Create Chat Request (OpenAI)
curl --request POST \
  --url https://llm.ai-nebula.com/v1/chat/completions \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "temperature": 123
}
'
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Artificial intelligence is a branch of computer science that aims to create intelligent machines..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 100,
    "total_tokens": 125
  }
}

Introduction

Universal text chat API supporting OpenAI-compatible large language models.

Authentication

Authorization
string
required
Bearer Token, e.g. Bearer sk-xxxxxxxxxx

Request Parameters

model
string
required
Model identifier, e.g. claude-sonnet-4-20250514, GPT-4o
messages
array
required
Message list, each containing role (user/system/assistant) and content
temperature
number
default:"0.7"
Randomness control, 0-2, higher values = more random

cURL Example

curl https://llm.ai-nebula.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-XyLy**************************mIqSt" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant"},
      {"role": "user", "content": "Briefly introduce artificial intelligence"}
    ],
    "temperature": 0.7
  }'

Python Example

from openai import OpenAI

client = OpenAI(
    api_key="sk-XyLy**************************mIqSt",
    base_url="https://llm.ai-nebula.com/v1"
)

completion = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Briefly introduce artificial intelligence"}
    ],
    temperature=0.7
)

print(completion.choices[0].message.content)
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Artificial intelligence is a branch of computer science that aims to create intelligent machines..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 100,
    "total_tokens": 125
  }
}

Error Handling

ExceptionTriggerMessage
AuthenticationErrorInvalid API keyError: Invalid or unauthorized API key
NotFoundErrorModel not foundError: Model [model] does not exist
APIConnectionErrorNetwork errorError: Cannot connect to API server
APIErrorServer-side errorAPI request failed: [details]

Notes

  • system role defines model behavior, user role for questions
  • Multi-turn conversations require appending history (including assistant responses)
  • Requires openai library: pip install openai