Search

Search HiAPI models, tools, and resources.

Back to blog
Tutorial

How to Use gpt-6-luna via the hiapi API: curl, Python, and a Working Request

hiapigpt-6-lunatutorialtext-generation

What you'll build

A working call to gpt-6-luna on hiapi: one curl request, a Python client, then the parameters that behave differently from the other GPT-6 models. You need an API key from your dashboard; the quickstart covers key setup. Everything below was run against the live endpoint on 2026-10-29.

Confirm the model id

curl -s https://api.hiapi.ai/v1/models -H "Authorization: Bearer $HIAPI_API_KEY" \
  | python3 -c "import sys,json; print([m['id'] for m in json.load(sys.stdin)['data'] if 'luna' in m['id']])"

Output: ['gpt-5.6-luna', 'gpt-6-luna']. Use gpt-6-luna exactly (no .1, unlike gpt-6.1-sol and gpt-6.1-terra). gpt-5.6-luna is an older, separate model. The listing shows both openai (Chat Completions) and openai-response (Responses) endpoint types. The model page is gpt-6-luna.

Minimal request: Chat Completions with curl

curl -s https://api.hiapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $HIAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6-luna","messages":[{"role":"user","content":"Reply with exactly: luna ok"}]}'

Real response (trimmed to the fields that matter):

{"model":"gpt-6-luna","object":"chat.completion",
 "choices":[{"index":0,"message":{"role":"assistant","content":"luna ok"},"finish_reason":"stop"}],
 "usage":{"prompt_tokens":12,"completion_tokens":7,"total_tokens":19}}

No stream flag is needed on this route. That is the main practical difference from the Responses route below.

Python (standard library only)

import json, os, urllib.request

req = urllib.request.Request(
    "https://api.hiapi.ai/v1/chat/completions",
    data=json.dumps({
        "model": "gpt-6-luna",
        "messages": [
            {"role": "system", "content": "Answer in one sentence."},
            {"role": "user", "content": "What is a 1M-token context window good for?"},
        ],
    }).encode(),
    headers={
        "Authorization": "Bearer " + os.environ["HIAPI_API_KEY"],
        "Content-Type": "application/json",
    },
)
r = json.load(urllib.request.urlopen(req, timeout=90))
print(r["choices"][0]["message"]["content"])
print(r["usage"]["prompt_tokens"], r["usage"]["completion_tokens"])

This run returned a one-sentence answer about reading whole books, archives and codebases without chunking, with usage 27 101. Note that 101 completion tokens for one sentence is far more than the visible text. Luna is a reasoning model and the default effort is medium; see the reasoning section below.

The Responses route (stream required)

/v1/responses also works, with two constraints I hit directly:

curl -sN https://api.hiapi.ai/v1/responses \
  -H "Authorization: Bearer $HIAPI_API_KEY" -H "Content-Type: application/json" \
  -d '{"model":"gpt-6-luna","stream":true,"instructions":"Be terse.",
       "reasoning":{"effort":"low"},
       "input":[{"role":"user","content":"Name one use for a 1M context window."}]}'
import json, os, subprocess

body = {"model": "gpt-6-luna", "stream": True, "reasoning": {"effort": "low"},
        "input": [{"role": "user", "content": "Name one use for a 1M context window."}]}
out = subprocess.run(
    ["curl", "-sN", "https://api.hiapi.ai/v1/responses",
     "-H", "Authorization: Bearer " + os.environ["HIAPI_API_KEY"],
     "-H", "Content-Type: application/json", "-d", json.dumps(body)],
    capture_output=True, text=True, timeout=120).stdout
for line in out.splitlines():
    if line.startswith("data:"):
        ev = json.loads(line[5:])
        if ev.get("type") == "response.completed":
            r = ev["response"]
            print(r["output"][-1]["content"][0]["text"], r["usage"])

Result: Analyze a large codebase in one pass. with usage input_tokens 24, output_tokens 13, reasoning_tokens 0.

Choosing Chat Completions or Responses

Behaviour (tested 2026-10-29)/v1/chat/completions/v1/responses
stream omitted200, normal JSON400 invalid_parameter "stream: must be true"
stream: true200, chat.completion.chunk SSE200, SSE events ending in response.completed
input as plain stringn/a (messages)400 invalid_parameter "input: has incorrect type"; use an array
Token capmax_tokens and max_completion_tokens both enforcedmax_output_tokens accepted with 200

Chat Completions is the easier drop-in for existing OpenAI-compatible code. Pick Responses if you already use that API shape.

Tool calls and JSON output

Function calling works on the Chat route. With one get_weather(city) tool and the prompt "Weather in Paris?":

"message":{"role":"assistant","content":"","tool_calls":[{"type":"function",
  "function":{"name":"get_weather","arguments":"{\"city\":\"Paris\"}"}}]},
"finish_reason":"tool_calls"

Strict JSON schema output also works. With response_format: {"type":"json_schema", ... "strict":true} and the prompt "Give a city and country for the Eiffel Tower." the content was exactly {"city":"Paris","country":"France"}.

I only ran a single tool-call turn. I did not test sending the tool result back or parallel tool calls.

Reasoning effort and token billing

The pricing contract lists six levels for reasoning_effort: none, low, medium (default), high, xhigh, max. Same prompt ("What is 17*23? Answer with the number only."), same answer 391:

reasoning_effortcompletion tokensreasoning tokenswall time
none505.8 s
high25188.0 s

Reasoning tokens count toward completion tokens, so a short answer can bill more than its visible length. For extraction, classification and summarisation, try none or low first. I tested only this one arithmetic prompt, so this shows the mechanism, not a quality comparison.

Luna vs Sol vs Terra

From the live /api/pricing listing on 2026-10-29 (check pricing for current numbers):

  • Cost: Luna's standard input and output rates are about 1/10 of gpt-6.1-terra and about 1/20 of gpt-6.1-sol.
  • Context: all three list a 1,050,000-token context window. Above 272,000 input tokens Luna moves to a higher tier (input rate doubles, output rate rises by half).
  • Positioning in the model descriptions: Luna is described for focused, high-volume work such as summarisation, extraction and quick answers; Terra for visual reasoning and computer use; Sol for complex coding and multi-step professional work.
  • Latency: I did not measure a speed advantage. One identical "Reply with exactly: ok" request on the Chat route took 5.0 s on Luna, 4.1 s on Terra and 5.0 s on Sol. That is one sample each, so treat it as noise. Choose Luna for price, not for speed, unless your own benchmark shows otherwise.

I made no output-quality comparison between the three, so this article does not claim one.

Errors I reproduced

  • Bad key: HTTP 401-class permission_denied, "This API key is invalid." with a request_id.
  • Wrong id (gpt-6-lunaa): model_not_found, pointing you to GET /v1/models.
  • Responses route without stream:true or with string input: the two 400s in the table above.

Parameters to be careful with

  • temperature and top_p are marked disabled in the contract. The Chat route returned 200 when I sent temperature: 0.2, but I did not verify that it changes sampling. Don't rely on it for determinism.
  • The contract also marks max_tokens and max_completion_tokens as disabled, yet in testing max_tokens: 1 returned finish_reason: "length" with 1 completion token. In practice it is enforced on the Chat route. Remember that reasoning tokens count toward the cap, so a tiny cap with high effort can return empty content.
  • I did not test image input, a prompt near the 1M limit, or sustained concurrency.

FAQ

What is the gpt-6-luna model id? gpt-6-luna, as listed by GET /v1/models.

Does gpt-6-luna need streaming? Only on /v1/responses. /v1/chat/completions works with or without stream.

Does it support tool calls and JSON output? Yes, a single function call and a strict json_schema response both worked in testing.

How much does it cost? Pricing is per token with a higher tier above 272,000 input tokens. See pricing.

Generate it with HiAPI

Choose a model, enter your prompt, and see the result.

HiAPI Blog

Related articles

HiAPI

Generate it with HiAPI

Start generating