HiAPI
  • Models
  • Pricing
Search

Search HiAPI models, tools, and resources.

  • Models
  • Pricing
HiAPI

One API, All AI Models

Generate images, video, and audio with leading models through one production-ready API.

Get a free API key

AI Image API

  • All image models
  • GPT Image 2.5 Flare
  • GPT Image 2.5 Sunburst
  • GPT Image 2
  • Nano Banana 2
  • Seedream 5.0 Pro
  • Qwen Image 2.0 Pro
  • FLUX 1.1 Pro

AI Video API

  • All video models
  • Seedance 2.5
  • FLUX.3 Video
  • Seedance 2.0
  • Veo 3.1
  • Kling 3.0 Omni

AI Audio API

  • All audio models
  • MiniMax Music 2.6
  • MiniMax Music 1.5
  • ElevenLabs v3
  • Text to music
  • Text to speech

Product

  • Model marketplace
  • Playground
  • Pricing
  • Image API Cost Calculator
  • Free GPT Image 2 Generator
  • Free Background Remover
  • Free Nano Banana Image Generator
  • Outfit Preview
  • Product Photo Lab

Developers

  • Agent setup
  • Documentation
  • API Reference
  • Agent Skills
  • LLM integration index
  • Blog

Company

  • About
  • Contact support
  • Terms of Service
  • Privacy Policy

© 2026 hiapi. All rights reserved.

Open source on GitHubPython SDK on PyPI
  • What you'll build
  • Minimal runnable example
  • Production patterns
  • Streaming
  • Tool calls
  • Adaptive thinking
  • Error handling
  • Idempotency and retries
  • Related reading
  • FAQ
TutorialSep 21, 2026

How to Use Claude Opus 4.8 via the hiapi API

hiapiClaude Opus 4.8Chat Completions APIAPI TutorialAnthropic

Latest models

Explore models

Contents
  • What you'll build
  • Minimal runnable example
  • Production patterns
  • Streaming
  • Tool calls
  • Adaptive thinking
  • Error handling
  • Idempotency and retries
  • Related reading
  • FAQ

Generate it with HiAPI

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

HiAPI Blog

Related articles

HiAPI

Generate it with HiAPI

What you'll build

A working integration that calls Claude Opus 4.8 — the top-tier model in Anthropic's current Claude 4.8 lineup — through hiapi's OpenAI-compatible Chat Completions API. One request returns a real completion, plus the production patterns (streaming, tool calls, adaptive thinking) you'll need once the demo works.

Prerequisite: an hiapi API key. Grab one from the dashboard — it's a single sk-... string, and the same key works across every enabled model in your account, not just this one.

Everything below was run against the live API while writing this piece.

Minimal runnable example

Claude Opus 4.8 is a text model on the standard Chat Completions endpoint — not the async /v1/tasks flow hiapi uses for image/video/audio models. One request, one response, no polling.

curl https://api.hiapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-<your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [
      {"role": "user", "content": "Review this function for edge cases and suggest a fix."}
    ],
    "max_tokens": 1024
  }'

Response (trimmed):

{
  "id": "msg_011CfFm8abLRcYtLVSky81As",
  "model": "claude-opus-4-8",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 10, "completion_tokens": 4, "total_tokens": 14 }
}

Same call in Python, using only requests:

import requests

resp = requests.post(
    "https://api.hiapi.ai/v1/chat/completions",
    headers={"Authorization": "Bearer sk-<your-api-key>"},
    json={
        "model": "claude-opus-4-8",
        "messages": [
            {"role": "user", "content": "Review this function for edge cases and suggest a fix."}
        ],
        "max_tokens": 1024,
    },
    timeout=60,
)
resp.raise_for_status()
data = resp.json()
print(data["choices"][0]["message"]["content"])
print(data["usage"])  # prompt_tokens / completion_tokens / total_tokens

Send the bare model ID claude-opus-4-8 — no provider prefix, no route suffix. hiapi lists this model with two backing routes (default and aws) for redundancy, but they share one model ID; you never pick between them.

Because the shape is OpenAI-compatible, this also works unmodified with the official openai Python/JS SDKs — just point base_url at https://api.hiapi.ai/v1 and pass your hiapi key.

Production patterns

Streaming

Set "stream": true and read Server-Sent Events. Each chunk carries a delta.content fragment; the stream ends with finish_reason: "stop" on the final chunk followed by a [DONE] sentinel:

curl https://api.hiapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-<your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [{"role": "user", "content": "Count 1 to 3"}],
    "stream": true,
    "max_tokens": 20
  }'
data: {"choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":null,"index":0}]}

data: {"choices":[{"delta":{"content":"1"},"finish_reason":null,"index":0}]}

data: {"choices":[{"delta":{"content":", 2, 3"},"finish_reason":null,"index":0}]}

data: {"choices":[{"delta":{},"finish_reason":"stop","index":0}]}

data: [DONE]

Accumulate choices[0].delta.content across chunks to reconstruct the full text. The final data event (after finish_reason) carries the usage totals instead of a delta.

Tool calls

Declare functions the same way you would against OpenAI, then replay the assistant's tool_calls message plus a tool result message on the next turn:

curl https://api.hiapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-<your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "messages": [{"role": "user", "content": "What is the status of task demo-123?"}],
    "max_tokens": 200,
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_task_status",
        "description": "Look up a task by ID.",
        "parameters": {
          "type": "object",
          "properties": {"task_id": {"type": "string"}},
          "required": ["task_id"],
          "additionalProperties": false
        }
      }
    }],
    "tool_choice": "auto"
  }'

The response comes back with finish_reason: "tool_calls" and the function name plus JSON-encoded arguments in choices[0].message.tool_calls. Run your function locally, then send the result back as a role: "tool" message carrying a matching tool_call_id in the next request — the model continues from there.

Adaptive thinking

Claude Opus 4.8 supports an opt-in reasoning pass. Add "thinking": {"type": "adaptive"} and pick an effort level via output_config.effort (low, medium, or high are all confirmed working):

{
  "model": "claude-opus-4-8",
  "messages": [{"role": "user", "content": "Compare two approaches and state the trade-offs."}],
  "thinking": {"type": "adaptive"},
  "output_config": {"effort": "high"}
}

Two things worth knowing before you build around this. First, "adaptive" means the model decides on its own whether a prompt is worth thinking about — a trivial question at low or even medium effort can come back with no reasoning_details field at all, so don't assume every request produces one. Second, unlike some other text models on hiapi, Opus 4.8 doesn't return a human-readable trace: the reasoning_details array's reasoning.text entries come back empty, and only a signature entry is populated. Treat reasoning_details as opaque continuation state — pass it through unchanged if you carry the conversation into a follow-up tool call — not as something to parse or display to users.

Error handling

Auth failures return HTTP 401 with a hiapi_error envelope:

{
  "error": {
    "code": "permission_denied",
    "message": "This API key is invalid. Check that it is correct or use another API key and try again.",
    "type": "hiapi_error"
  }
}

Check response.status_code before touching response.json()["choices"], and log error.request_id if you need to escalate — support can trace a specific call from it.

Idempotency and retries

Chat Completions calls aren't idempotent by request ID the way /v1/tasks jobs are — a retried request is a new completion, and a new bill. For production traffic, wrap calls in your own retry-with-backoff on 5xx/timeouts, and cap max_tokens so a retry storm (or an adaptive-thinking call that runs long) can't run up an unbounded cost.

Related reading

  • Claude Opus 4.8 on hiapi — current pricing and model card.
  • Authentication — how hiapi API keys work and how to rotate them.
  • How to Use Claude Sonnet 4.6 via the hiapi API — the same integration pattern against hiapi's balanced-cost Claude tier, if Opus 4.8 is more model than your workload needs.
  • hiapi pricing — live per-token rates for Claude Opus 4.8 and every other enabled model.

FAQ

Is claude-opus-4-8 the exact model ID I should send? Yes — send the bare string claude-opus-4-8 in the model field. No provider-specific prefix and no route suffix needed; hiapi resolves it to the correct backing route internally.

Does this use the same /v1/tasks flow as hiapi's image and video models? No. Text models like Claude Opus 4.8 use the synchronous POST /v1/chat/completions endpoint — one request, one response (or one SSE stream). /v1/tasks is only for media models (image, video, audio), which run async and return a URL to poll or a callback.

Can I use the OpenAI SDK instead of raw curl/requests? Yes. Since the endpoint is OpenAI-compatible, point the official openai SDK's base_url at https://api.hiapi.ai/v1 and use your hiapi key as the api_key — no other code changes needed for basic chat, streaming, or tool calls.

Should I use Opus 4.8 or Sonnet 4.6? Opus 4.8 is the higher-capability, higher-cost tier — reach for it on harder reasoning, coding, or agentic tasks where accuracy matters more than latency or per-token cost. For high-volume or latency-sensitive traffic, Claude Sonnet 4.6 is the same API shape at a lower price point.

Will thinking always return a visible reasoning trace? No, on both counts: adaptive thinking may skip reasoning entirely for a request it judges simple, and when it does think, Opus 4.8's reasoning_details currently comes back with an empty text field — only the signature is populated. Don't build a UI that assumes a readable trace is always present.

Where do I check current pricing before running a large batch? hiapi's pricing page lists live per-token rates for Claude Opus 4.8 — check it before budgeting, since this article doesn't hardcode a number that could go stale.

Latest models

View all models
  • GPT Image 2.5 FlareFrom $0.050/image
  • GPT Image 2.5 SunburstFrom $0.050/image
  • GPT Image 2From $0.030/image
  • Nano Banana 2From $0.051/image

Explore models

TextImageVideoAudio
Back to blog
GPT Image 2.5 FlareFrom $0.050/image
GPT Image 2.5 SunburstFrom $0.050/image
GPT Image 2From $0.030/image
Nano Banana 2From $0.051/image
View all models
TextChat and reasoning
ImageGenerate and edit
VideoText and image to video
AudioSpeech and music
Start generating
View model pricing
View all articles
GPT Image 2 / 2.5 with n8n: The request worked. Where is the image?

GPT Image 2 / 2.5 with n8n: The request worked. Where is the image?

FLUX.2 Text-to-Image API: Parameters, Code, and a Working Example

FLUX.2 Text-to-Image API: Parameters, Code, and a Working Example

How to Use the Nano Banana 2 API: A Complete Tutorial

How to Use the Nano Banana 2 API: A Complete Tutorial

How to Use glm-5.3 via the hiapi API: curl, Python, and a Working Request

How to Use glm-5.3 via the hiapi API: curl, Python, and a Working Request

How to Use Claude Sonnet 4.6 via the hiapi API

How to Use Claude Sonnet 4.6 via the hiapi API

How to Use kimi-k3 via the hiapi API: curl, Python, and a Working Request

How to Use kimi-k3 via the hiapi API: curl, Python, and a Working Request

Start generating