claude-opus-4-8
Claude Opus 4.8 — Anthropic's most capable model for complex reasoning and agentic coding. OpenAI-compatible /api/v1/chat/completions on reapi.ai with 1M context, 128K max output, vision input, and prompt caching.
Claude Opus 4.8 is Anthropic's most capable model for complex reasoning and long-horizon agentic coding, exposed through reAPI as a drop-in OpenAI-compatible Chat Completions endpoint. 1M token context, 128K max output, vision input, prompt caching, and tool use. Current rates live on the model page.
This model uses the unified reAPI key and balance through Chat Completions. No group lookup or group parameter is required. Native /api/v1/messages currently serves Opus 5.5, Fable 5 and Fable 5.1; it does not accept claude-opus-4-8. Current prices and the discount against official input/output pricing are published on the model page and in its machine-readable reference, using a five-minute price cache.
Quick example
curl https://reapi.ai/api/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-8",
"messages": [
{ "role": "user", "content": "Hello" }
],
"stream": true,
"max_tokens": 4096,
"temperature": 0.7
}'from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://reapi.ai/api/v1",
)
stream = client.chat.completions.create(
model="claude-opus-4-8",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
max_tokens=4096,
temperature=0.7,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://reapi.ai/api/v1",
});
const stream = await client.chat.completions.create({
model: "claude-opus-4-8",
messages: [{ role: "user", content: "Hello" }],
stream: true,
max_tokens: 4096,
temperature: 0.7,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "claude-opus-4-8",
"messages": []map[string]string{
{"role": "user", "content": "Hello"},
},
"stream": true,
"max_tokens": 4096,
"temperature": 0.7,
})
req, _ := http.NewRequest("POST",
"https://reapi.ai/api/v1/chat/completions", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
}Authentication
Use your reAPI API key — the same key that calls the image, video and audio endpoints — as a bearer token:
Authorization: Bearer YOUR_API_KEYCreate one under API keys in your reAPI dashboard. Chat requests are billed from the same credit balance as every other model on the platform.
Endpoint
POST /api/v1/chat/completionsBase URL https://reapi.ai/api/v1. The wire format is OpenAI-compatible, so the
same SDKs work once you swap the base URL, the key and the model string. The
model id is claude-opus-4-8.
Request body
model — string, required
Must be "claude-opus-4-8". The value is echoed back in the response
envelope.
messages — array, required
Conversation history as an array of message objects. Same shape as the OpenAI Chat Completions spec, plus content-parts for vision:
{
"role": "system" | "user" | "assistant" | "tool",
"content": "string OR content-parts array (text + image_url parts)"
}Multi-turn history is sent in chronological order — the last message is the one Claude responds to.
max_tokens — optional integer
Upper bound on output tokens, up to 128000. On this Chat Completions endpoint it is optional; omission uses the registered model ceiling. 4096 in the examples is a sample cap, not the API default. max_completion_tokens is also accepted; when both fields are present, the smaller value is used.
stream — boolean, default false
When true, the response is streamed as server-sent events (SSE) with
Content-Type: text/event-stream. Each event is a JSON delta in the
OpenAI format, terminated by a data: [DONE] line.
temperature — number, default 1
Range 0.0 – 1.0. Sampling temperature. Anthropic recommends
either temperature or top_p, not both. Lower values produce
more deterministic output.
top_p — number, default 1
Range 0.0 – 1.0. Nucleus sampling cutoff.
tools / tool_choice — optional
Standard OpenAI tool-calling parameters. Claude Opus 4.8 supports the
full OpenAI tool-use spec via this surface and uses tools more
efficiently than prior Opus models — fewer steps for the same result.
Anthropic's native tool-use schema (cache_control, tool_choice_type) is
not part of the Chat Completions shape and is not exposed on this endpoint.
Vision input (multimodal)
Send images alongside text via OpenAI content-parts:
{
"model": "claude-opus-4-8",
"max_tokens": 4096,
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "What does this chart show?" },
{
"type": "image_url",
"image_url": { "url": "https://example.com/chart.png" }
}
]
}
]
}Supported image formats: PNG, JPEG, GIF, WebP. Base64 URLs work too —
prefix data:image/png;base64,.... Each image counts toward the input
token budget based on its resolution.
Prompt caching
Anthropic's prompt caching pays off on stable system prompts, recurring RAG context, and long multi-turn agent histories. The first call pays the cache-write rate on the cacheable region; subsequent calls within the cache window pay only the (much lower) cache-read rate on those tokens.
Caching is controlled by cache_control blocks on Anthropic's native
Messages API, which is not part of the Chat Completions shape on this
endpoint. Whether a request is served from cache is decided upstream; each
request is charged the exact amount the serving gateway settled it at, so any
cache effect is already included in the settled charge. Internal cost fields are not returned in the public response. The current catalogue does not publish a separate cache rate for this model, so no cache discount should be inferred from another model or from Anthropic's own rate card.
Response shape
Non-streaming (stream: false)
{
"id": "chatcmpl-018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
"object": "chat.completion",
"created": 1735000000,
"model": "claude-opus-4-8",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21,
"prompt_tokens_details": {
"cached_tokens": 0
}
}
}usage.prompt_tokens_details.cached_tokens reports how many input
tokens were served from cache. This usage count alone does not establish a separate reAPI cache rate.
Streaming (stream: true)
Content-Type: text/event-stream. Each data: line is a JSON delta in
the OpenAI chunk format; the final event before [DONE] carries the
finish_reason (stop / length / tool_calls / content_filter).
Pricing
Claude Opus 4.8 is billed pay-as-you-go from your reAPI credit balance (1 credit = $0.001). Current input/output rates and the comparison with official pricing are on the model page and in llms.txt. Prices refresh from the live catalogue with a five-minute cache; the displayed discount is already included in those rates.
Settlement uses the actual request cost, including any applicable cache effects. Do not calculate a charge using unpublished cache or web-search rates. Failed requests are not charged.
Limits
| Limit | Value |
|---|---|
| Context window | 1M tokens |
| Max output per call | 128K tokens |
Streams that hit the output cap finish with finish_reason: "length";
call again with a continuation message if you need more text.
Errors
The error envelope follows the OpenAI shape — HTTP status, plus a JSON body:
{
"error": {
"message": "...",
"type": "invalid_request_error",
"code": "..."
}
}Common cases:
| Status | When | Notes |
|---|---|---|
400 | Missing max_tokens, bad shape, etc. | Anthropic requires max_tokens; OpenAI SDKs that omit it will 400 here |
401 | Missing / invalid API key | Create a key under API keys in the reAPI dashboard |
402 | Insufficient balance | Top up your reAPI credits |
429 | Rate limit hit | Back off and retry |
500 | Upstream / gateway error | Safe to retry — failed calls are not charged |
reAPI does not internally retry chat requests. Every customer call maps to exactly one upstream POST. If a network error reaches you, that's a one-for-one wire failure and a retry from your side is safe; the upstream provider may have already produced output, but the gateway will not double-bill.
Recipes
Minimum request
{
"model": "claude-opus-4-8",
"max_tokens": 4096,
"messages": [
{ "role": "user", "content": "Summarise this in three sentences." }
]
}Tool use (function calling, OpenAI surface)
{
"model": "claude-opus-4-8",
"max_tokens": 4096,
"messages": [
{ "role": "user", "content": "What's the weather in Tokyo today?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Look up the current weather for a city.",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}Vision
{
"model": "claude-opus-4-8",
"max_tokens": 4096,
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Read the error in this screenshot and suggest a fix." },
{
"type": "image_url",
"image_url": { "url": "https://your-cdn.com/screenshot.png" }
}
]
}
]
}When to pick Claude Opus 4.8
Pick Claude Opus 4.8 when output quality and reliability dominate the decision:
- Long-horizon agentic coding — multi-service refactors, codebase-scale migrations, and agent runs that must stay on-task across many steps.
- High-stakes reasoning — work where a confident-but-wrong answer has real downstream cost. Opus 4.8 is more likely to flag uncertainty than to overclaim.
- Large-context analysis — full codebases, long research packs, multi-document review, audit work.
Route lighter traffic (classification, short replies, tight loops) to cheaper Claude or GPT models on the same key.
Tips
- Set
max_tokensgenerously. Anthropic enforces it strictly — the model still stops at the natural end of its response, but a low cap will truncate before the real ending. - Stream by default for chat UX. Streaming cuts perceived latency dramatically.
- Cache the stable parts of long prompts. A 500K-token RAG context on top of a 1KB user question can pay the cache-read rate on every subsequent call instead of the standard input rate — a big saving on multi-turn agents replaying long histories.
- Tune
temperatureortop_p, not both. Mixing them produces results that are hard to reason about.