from anthropic import Anthropic
import os
# π₯ Create an Anthropic client, pointed at Muna
anthropic = Anthropic(
api_key=os.environ["MUNA_API_KEY"],
base_url="https://inference.muna.ai"
)
# π₯ Create a message
message = anthropic.messages.create(
model="@qwen/qwen-3.8-27b",
max_tokens=1024,
messages=[{ "role": "user", "content": "What is the capital of France?" }]
)
# π Print the result
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk"
// π₯ Create an Anthropic client, pointed at Muna
const anthropic = new Anthropic({
apiKey: process.env.MUNA_API_KEY,
baseURL: "https://inference.muna.ai"
});
// π₯ Create a message
const message = await anthropic.messages.create({
model: "@qwen/qwen-3.8-27b",
max_tokens: 1024,
messages: [{ role: "user", content: "What is the capital of France?" }]
});
// π Print the result
console.log(message.content[0].text);
# π₯ Stream a message
with anthropic.messages.stream(
model="@qwen/qwen-3.8-27b",
max_tokens=1024,
messages=[{ "role": "user", "content": "What is life?" }]
) as stream:
# π Use text deltas
for text in stream.text_stream:
...
curl https://inference.muna.ai/v1/messages \
-H "x-api-key: $MUNA_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "@qwen/qwen-3.8-27b",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "What is the capital of France?" }]
}'
{
"id": "msg_6f1c2b9e4d3a4b8e9c1f2a7d",
"type": "message",
"role": "assistant",
"model": "@qwen/qwen-3.8-27b",
"content": [
{ "type": "text", "text": "The capital of France is Paris." }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 16,
"output_tokens": 8,
"cache_read_input_tokens": 0
}
}
Anthropic
Create a Message
POST
/
v1
/
messages
from anthropic import Anthropic
import os
# π₯ Create an Anthropic client, pointed at Muna
anthropic = Anthropic(
api_key=os.environ["MUNA_API_KEY"],
base_url="https://inference.muna.ai"
)
# π₯ Create a message
message = anthropic.messages.create(
model="@qwen/qwen-3.8-27b",
max_tokens=1024,
messages=[{ "role": "user", "content": "What is the capital of France?" }]
)
# π Print the result
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk"
// π₯ Create an Anthropic client, pointed at Muna
const anthropic = new Anthropic({
apiKey: process.env.MUNA_API_KEY,
baseURL: "https://inference.muna.ai"
});
// π₯ Create a message
const message = await anthropic.messages.create({
model: "@qwen/qwen-3.8-27b",
max_tokens: 1024,
messages: [{ role: "user", content: "What is the capital of France?" }]
});
// π Print the result
console.log(message.content[0].text);
# π₯ Stream a message
with anthropic.messages.stream(
model="@qwen/qwen-3.8-27b",
max_tokens=1024,
messages=[{ "role": "user", "content": "What is life?" }]
) as stream:
# π Use text deltas
for text in stream.text_stream:
...
curl https://inference.muna.ai/v1/messages \
-H "x-api-key: $MUNA_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "@qwen/qwen-3.8-27b",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "What is the capital of France?" }]
}'
{
"id": "msg_6f1c2b9e4d3a4b8e9c1f2a7d",
"type": "message",
"role": "assistant",
"model": "@qwen/qwen-3.8-27b",
"content": [
{ "type": "text", "text": "The capital of France is Paris." }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 16,
"output_tokens": 8,
"cache_read_input_tokens": 0
}
}
Creates a message. Pass
stream: true to stream the message as server-sent events.
from anthropic import Anthropic
import os
# π₯ Create an Anthropic client, pointed at Muna
anthropic = Anthropic(
api_key=os.environ["MUNA_API_KEY"],
base_url="https://inference.muna.ai"
)
# π₯ Create a message
message = anthropic.messages.create(
model="@qwen/qwen-3.8-27b",
max_tokens=1024,
messages=[{ "role": "user", "content": "What is the capital of France?" }]
)
# π Print the result
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk"
// π₯ Create an Anthropic client, pointed at Muna
const anthropic = new Anthropic({
apiKey: process.env.MUNA_API_KEY,
baseURL: "https://inference.muna.ai"
});
// π₯ Create a message
const message = await anthropic.messages.create({
model: "@qwen/qwen-3.8-27b",
max_tokens: 1024,
messages: [{ role: "user", content: "What is the capital of France?" }]
});
// π Print the result
console.log(message.content[0].text);
# π₯ Stream a message
with anthropic.messages.stream(
model="@qwen/qwen-3.8-27b",
max_tokens=1024,
messages=[{ "role": "user", "content": "What is life?" }]
) as stream:
# π Use text deltas
for text in stream.text_stream:
...
curl https://inference.muna.ai/v1/messages \
-H "x-api-key: $MUNA_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "@qwen/qwen-3.8-27b",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "What is the capital of France?" }]
}'
{
"id": "msg_6f1c2b9e4d3a4b8e9c1f2a7d",
"type": "message",
"role": "assistant",
"model": "@qwen/qwen-3.8-27b",
"content": [
{ "type": "text", "text": "The capital of France is Paris." }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 16,
"output_tokens": 8,
"cache_read_input_tokens": 0
}
}
Body
string
required
Model tag.
integer
required
Maximum number of tokens to generate.
MessageParam[]
required
Input messages. Content blocks can be
text, image, tool_use, or tool_result.string | TextBlock[]
System prompt.
boolean
Whether to stream the message as server-sent events. Defaults to
false.Tool[]
Tools the model may call.
ThinkingConfig
Extended thinking configuration:
{ "type": "disabled" }, { "type": "enabled", "budget_tokens": N },
or { "type": "adaptive" }. Mapped onto the modelβs reasoning effort.string
Reasoning effort:
low, medium, high, xhigh, or max.number
Sampling temperature.
number
Nucleus sampling coefficient.
integer
Only sample from the top K options for each token. Ignored by models that do not support it.
string[]
Custom text sequences that stop generation. Ignored by models that do not support it.
Response
string
required
Message identifier.
string
required
Object type, always
message.string
required
Message role, always
assistant.string
required
Model tag.
ContentBlock[]
required
Generated content. Blocks can be
text, thinking, or tool_use.string
Reason the model stopped generating:
end_turn, max_tokens, stop_sequence, or tool_use.string
Custom stop sequence that was generated, if any.