pydo.messages.create()
Generated on 3 Aug 2026
from pydo version
v0.40.0
Usage
client.messages.create(
model="claude-opus-4-6",
max_tokens=1024,
messages=[
{"role": "user", "content": "What is the capital of Portugal?"},
],
)Serverless inference methods can authenticate with a model access key instead of a DigitalOcean API token:
client = Client(token=os.environ.get("MODEL_ACCESS_KEY"))Description
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
Parameters
modelstring requiredExample:
claude-opus-4-6Model ID (for example
claude-opus-4-6or a serverless model id).max_tokensinteger requiredMaximum tokens to generate before stopping.
messagesarray of objects requiredConversation turns. Each item has
roleuserorassistantandcontentas a string or an array of content blocks.Show child properties
rolestring requiredSpeaker role for this message.
contentobject requiredExample:
What is the capital of Portugal?Message body as plain text or structured blocks.
systemobject optionalSystem prompt as plain text or as an array of text blocks.
stop_sequencesarray of strings optionalCustom strings that stop generation when produced.
streamboolean optionalWhen true, the response is streamed using server-sent events (SSE).
temperaturenumber or null optionalSampling temperature between 0.0 and 1.0.
top_pnumber or null optionalNucleus sampling; use either
temperatureortop_p, not both.top_kinteger or null optionalTop-K sampling cutoff.
toolsarray of objects optionalTool definitions the model may invoke.
Show child properties
namestring requiredExample:
get_weatherTool name referenced in
tool_useblocks.descriptionstring optionalExample:
Get the current weather for a location.Human-readable description of what the tool does.
input_schemaobject requiredJSON Schema (draft 2020-12 style) describing the tool input object.
tool_choiceobject optionalControls how the model uses tools: automatic selection, require any tool, force a specific tool, or a string form accepted by the service.
Show child properties
typestring requiredTool selection mode.
namestring optionalExample:
get_weatherWhen
typeistool, the tool name to use.
metadataobject optionalOptional request metadata.
Show child properties
user_idstring optionalExample:
550e8400-e29b-41d4-a716-446655440000Opaque identifier for the end user (for example a UUID or hash). Do not include PII.
reasoning_effortstring or null optionalDigitalOcean extension for reasoning-capable models. Ignored by executors that do not support it.
speedstring or null optionalDigitalOcean extension for preferred inference speed. Ignored when not supported.
thinkingobject or null optionalExtended thinking configuration. Executors that do not support thinking may ignore this field.
Show child properties
typestring requiredExample:
enabledThinking mode discriminator (for example enabled or disabled).
Request Sample
Response Example
More Information
See /v1/messages in the API reference for additional detail on responses, headers, parameters, and more.