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?"},
    ],
)
Returns JSONRaises HttpResponseError

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

model string required

Example: claude-opus-4-6

Model ID (for example claude-opus-4-6 or a serverless model id).

max_tokens integer required

Maximum tokens to generate before stopping.

Min: 1

messages array of objects required

Conversation turns. Each item has role user or assistant and content as a string or an array of content blocks.

Show child properties
role string required

Speaker role for this message.

One of: user, assistant

content object required

Example: What is the capital of Portugal?

Message body as plain text or structured blocks.

system object optional

System prompt as plain text or as an array of text blocks.

stop_sequences array of strings optional

Custom strings that stop generation when produced.

stream boolean optional

When true, the response is streamed using server-sent events (SSE).

Default: False

temperature number or null optional

Sampling temperature between 0.0 and 1.0.

Min: 0

Max: 1

top_p number or null optional

Nucleus sampling; use either temperature or top_p, not both.

top_k integer or null optional

Top-K sampling cutoff.

Min: 0

tools array of objects optional

Tool definitions the model may invoke.

Show child properties
name string required

Example: get_weather

Tool name referenced in tool_use blocks.

description string optional

Example: Get the current weather for a location.

Human-readable description of what the tool does.

input_schema object required

JSON Schema (draft 2020-12 style) describing the tool input object.

tool_choice object optional

Controls 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
type string required

Tool selection mode.

One of: auto, any, tool

name string optional

Example: get_weather

When type is tool, the tool name to use.

metadata object optional

Optional request metadata.

Show child properties
user_id string optional

Example: 550e8400-e29b-41d4-a716-446655440000

Opaque identifier for the end user (for example a UUID or hash). Do not include PII.

reasoning_effort string or null optional

DigitalOcean extension for reasoning-capable models. Ignored by executors that do not support it.

One of: none, minimal, low, medium, high, xhigh

speed string or null optional

DigitalOcean extension for preferred inference speed. Ignored when not supported.

One of: standard, fast

thinking object or null optional

Extended thinking configuration. Executors that do not support thinking may ignore this field.

Show child properties
type string required

Example: enabled

Thinking mode discriminator (for example enabled or disabled).

Request Sample

Show Request Sample
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "What is the capital of Portugal?"},
    ],
)

print(resp.content[0].text)

Response Example

Show Response Example
{
  "id": "msg_01AbCdEfGhIjKlMnOpQrStUv",
  "type": "message",
  "role": "assistant",
  "content": [],
  "model": "claude-opus-4-6",
  "stop_reason": "end_turn",
  "stop_sequence": "string",
  "usage": {
    "input_tokens": 42,
    "output_tokens": 128,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "speed": "standard"
  }
}

More Information

See /v1/messages in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.