Messages
POST https://api.fenno.ai/v1/messages
x-api-key: <FENNO_API_KEY>
anthropic-version: 2023-06-01
Content-Type: application/jsonRequest fields
| Field | Type | Meaning |
|---|---|---|
model | string, required | Exact Messages-capable model ID |
max_tokens | integer, required | Output-token limit within the selected model’s bounds |
messages | array, required | User/assistant history; content is a string or supported blocks |
system | string or array, optional | System guidance outside the messages array |
stream | boolean | Return message and content-block events |
tools | array, optional | Definitions with name, description and input_schema |
tool_choice, thinking | object, optional | Only supported values for the selected model |
Python example
Install anthropic; set FENNO_API_KEY and a Messages-capable FENNO_MODEL:
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.fenno.ai",
api_key=os.environ["FENNO_API_KEY"],
timeout=60.0,
max_retries=0,
)
response = client.messages.create(
model=os.environ["FENNO_MODEL"],
max_tokens=512,
system="Answer concisely.",
messages=[{"role": "user", "content": "What is an API gateway?"}],
)
for block in response.content:
if block.type == "text":
print(block.text)
print(response.stop_reason)Content and stop reasons
content[] is not always a single text block. Handle blocks by type: text, image/document input, tool_use, and supported thinking blocks are structurally different. Preserve model-required non-text blocks when carrying a conversation forward.
Common stop reasons include end_turn, max_tokens, stop_sequence and tool_use. A tool_use stop means the application should process allowed tool calls, not display them as a final answer. A max_tokens stop may leave output incomplete.
For a tool call, keep the assistant’s tool_use block and return a user message containing a tool_result with the matching tool_use_id. Do not place Chat Completions role: tool messages into this protocol.
Streaming lifecycle
message_start
content_block_start -> content_block_delta* -> content_block_stop
message_delta -> message_stopThere can be multiple content blocks, pings and error events. A delta can contain text, partial tool JSON or thinking data. Associate it with the block index and collect complete arguments before parsing.
The SDK’s client.messages.stream(...) context manager exposes text_stream for simple text use. Applications using tools must also process non-text content and the final stop reason.
See function calling, prompt caching, and error formats.