Skip to Content

Messages

POST https://api.fenno.ai/v1/messages x-api-key: <FENNO_API_KEY> anthropic-version: 2023-06-01 Content-Type: application/json

Request fields

FieldTypeMeaning
modelstring, requiredExact Messages-capable model ID
max_tokensinteger, requiredOutput-token limit within the selected model’s bounds
messagesarray, requiredUser/assistant history; content is a string or supported blocks
systemstring or array, optionalSystem guidance outside the messages array
streambooleanReturn message and content-block events
toolsarray, optionalDefinitions with name, description and input_schema
tool_choice, thinkingobject, optionalOnly 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_stop

There 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.