Agent Inference

Generated on 13 Apr 2026

DigitalOcean Gradient™ AI Agentic Cloud allows you to create multi-agent workflows to power your AI applications. This allows developers to integrate agents into your AI applications.

Note: The Agent Inference API uses a customer-specific base URL (the agent endpoint) and is independent of the main DigitalOcean control-plane API (https://api.digitalocean.com).

Base URL https://{your-agent-url}

POST Create a model response for the given chat conversation

/api/v1/chat/completions
Authorizations: inference_bearer_auth
Http: Bearer

Inference API Authentication

The Inference APIs use API access keys for authentication, which are separate from the DigitalOcean OAuth tokens used by the control-plane API.

Include the key as a Bearer token in the Authorization header of each request. All requests must be made over HTTPS.

Key Types

API Key Type Key Pattern How to Obtain
Serverless Inference Model access key sk-do-* (e.g., sk-do-v1-abcd1234...) Generate in the AI/ML section of the DigitalOcean control panel
Agent Inference Endpoint access key Alphanumeric string (e.g., Abc1Def2Ghi3Jkl4...) Provided when provisioning an agent endpoint

Authenticate with a Bearer Authorization Header

Serverless Inference:

curl -X POST -H "Authorization: Bearer $MODEL_ACCESS_KEY" "https://inference.do-ai.run/v1/chat/completions"

Agent Inference:

curl -X POST -H "Authorization: Bearer $AGENT_ACCESS_KEY" "https://{your-agent-url}.agents.do-ai.run/v1/chat/completions?agent=true"

Note: These keys are not interchangeable with DigitalOcean OAuth tokens (dop_v1_*, doo_v1_*, dor_v1_*). OAuth tokens are used exclusively with the control-plane API at https://api.digitalocean.com.

Creates a model response for the given chat conversation via a customer-provisioned agent endpoint.

Query Parameters

agent boolean required
Example: true

Must be set to true for agent-based completion behavior.

Default: true

Request Body: application/json

frequency_penalty number optional Nullable

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

logit_bias object optional Nullable

Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

logprobs boolean optional Nullable

Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.

max_completion_tokens integer optional Nullable

The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run.

max_tokens integer optional Nullable

The maximum number of tokens that can be generated in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length.

messages array of object required

A list of messages comprising the conversation so far.

Show child properties
content string optional Nullable
Example: Hello, how are you?

The contents of the message.

reasoning_content string optional Nullable

The reasoning content generated by the model (assistant messages only).

refusal string optional Nullable

The refusal message generated by the model (assistant messages only).

role string, one of: system, developer, user, assistant, tool required
Example: user

The role of the message author.

tool_call_id string optional
Example: call_abc123

Tool call that this message is responding to (tool messages only).

tool_calls array of object optional

The tool calls generated by the model (assistant messages only).

Show child properties
function object required
Show child properties
arguments string required
Example: {"location": "Boston"}

The arguments to call the function with, as generated by the model in JSON format.

name string required
Example: get_weather

The name of the function to call.

id string required
Example: call_abc123

The ID of the tool call.

type string, one of: function required
Example: function

The type of the tool. Currently, only function is supported.

metadata object optional Nullable

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

model string required
Example: llama3-8b-instruct

Model ID used to generate the response.

n integer optional Nullable
Example: 1

How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.

presence_penalty number optional Nullable

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

reasoning_effort string (enum) optional Nullable

Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.

seed integer optional Nullable

If specified, the system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed.

stop array | string optional

Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

stream boolean optional Nullable

If set to true, the model response data will be streamed to the client as it is generated using server-sent events.

stream_options object optional Nullable

Options for streaming response. Only set this when you set stream to true.

Show child properties
include_usage boolean optional

If set, an additional chunk will be streamed before the data [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array.

temperature number optional Nullable
Example: 1

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.

tool_choice string, one of: none, auto, required | object optional

Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool. none is the default when no tools are present. auto is the default if tools are present.

Show child properties
function object required
Show child properties
name string required
Example: get_weather

The name of the function to call.

type string, one of: function required
Example: function
tools array of object optional

A list of tools the model may call. Currently, only functions are supported as a tool.

Show child properties
function object required
Show child properties
description string optional
Example: Get the current weather for a location.

A description of what the function does, used by the model to choose when and how to call the function.

name string required
Example: get_weather

The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

parameters object optional

The parameters the function accepts, described as a JSON Schema object.

type string, one of: function required
Example: function

The type of the tool. Currently, only function is supported.

top_logprobs integer optional Nullable

An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.

top_p number optional Nullable
Example: 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.

user string optional
Example: user-1234

A unique identifier representing your end-user, which can help DigitalOcean to monitor and detect abuse.

Content type application/json
{
  "frequency_penalty": 0,
  "logprobs": false,
  "max_completion_tokens": 0,
  "max_tokens": 0,
  "messages": [
    {
      "content": "Hello, how are you?",
      "reasoning_content": "string",
      "refusal": "string",
      "role": "user",
      "tool_call_id": "call_abc123",
      "tool_calls": []
    }
  ],
  "model": "llama3-8b-instruct",
  "n": 1,
  "presence_penalty": 0,
  "reasoning_effort": "none",
  "seed": 0,
  "stop": "string",
  "stream": false,
  "stream_options": {
    "include_usage": true
  },
  "temperature": 1,
  "tool_choice": "none",
  "tools": [
    {
      "type": "function"
    }
  ],
  "top_logprobs": 0,
  "top_p": 1,
  "user": "user-1234"
}
curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AGENT_ACCESS_KEY" \
  -d '{"messages": [{"role": "user", "content": "What is the capital of Portugal?"}], "model": "ignored"}' \
  "https://$AGENT_URL/api/v1/chat/completions?agent=true"

Responses

200

Successful chat completion. When stream is true, response is sent as Server-Sent Events (text/event-stream); otherwise a single JSON object (application/json) is returned.

ratelimit-limit integer

The default limit on number of requests that can be made per hour and per minute. Current rate limits are 5000 requests per hour and 250 requests per minute.

ratelimit-remaining integer

The number of requests in your hourly quota that remain before you hit your request limit. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

ratelimit-reset integer

The time when the oldest request will expire. The value is given in Unix epoch time. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

choices array of object required

A list of chat completion choices. Can be more than one if n is greater than 1.

Show child properties
finish_reason string, one of: stop, length, tool_calls, content_filter required
Example: stop

The reason the model stopped generating tokens. stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, tool_calls if the model called a tool.

index integer required
Example: 0

The index of the choice in the list of choices.

logprobs object required Nullable

Log probability information for the choice.

Show child properties
content array of object required Nullable

A list of message content tokens with log probability information.

Show child properties
bytes array of integer required Nullable

A list of integers representing the UTF-8 bytes representation of the token. Can be null if there is no bytes representation for the token.

logprob number required
Example: -1.2345

The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.

token string required
Example: Hello

The token.

top_logprobs array of object required

List of the most likely tokens and their log probability, at this token position.

Additional nested properties not shown. Refer to the full API spec for details.
refusal array of object required Nullable

A list of message refusal tokens with log probability information.

Show child properties
bytes array of integer required Nullable

A list of integers representing the UTF-8 bytes representation of the token. Can be null if there is no bytes representation for the token.

logprob number required
Example: -1.2345

The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.

token string required
Example: Hello

The token.

top_logprobs array of object required

List of the most likely tokens and their log probability, at this token position.

Additional nested properties not shown. Refer to the full API spec for details.
message object required

A chat completion message generated by the model.

Show child properties
content string required Nullable
Example: Hello! How can I help you today?

The contents of the message.

reasoning_content string required Nullable

The reasoning content generated by the model.

refusal string required Nullable

The refusal message generated by the model.

role string, one of: assistant required
Example: assistant

The role of the author of this message.

tool_calls array of object optional

The tool calls generated by the model, such as function calls.

Show child properties
function object required
Additional nested properties not shown. Refer to the full API spec for details.
id string required
Example: call_abc123

The ID of the tool call.

type string, one of: function required
Example: function

The type of the tool.

created integer required
Example: 1677649420

The Unix timestamp (in seconds) of when the chat completion was created.

id string required
Example: chatcmpl-abc123

A unique identifier for the chat completion.

model string required
Example: llama3-8b-instruct

The model used for the chat completion.

object string, one of: chat.completion required
Example: chat.completion

The object type, which is always chat.completion.

usage object optional

Usage statistics for the completion request.

Show child properties
cache_created_input_tokens integer required
Example: 0

Number of prompt tokens written to cache.

cache_creation object required

Breakdown of prompt tokens written to cache.

Show child properties
ephemeral_1h_input_tokens integer required
Example: 0

Number of prompt tokens written to 1h cache.

ephemeral_5m_input_tokens integer required
Example: 0

Number of prompt tokens written to 5m cache.

cache_read_input_tokens integer required
Example: 0

Number of prompt tokens read from cache.

completion_tokens integer required
Example: 20

Number of tokens in the generated completion.

prompt_tokens integer required
Example: 10

Number of tokens in the prompt.

total_tokens integer required
Example: 30

Total number of tokens used in the request (prompt + completion).

401

Authentication failed due to invalid credentials.

ratelimit-limit integer

The default limit on number of requests that can be made per hour and per minute. Current rate limits are 5000 requests per hour and 250 requests per minute.

ratelimit-remaining integer

The number of requests in your hourly quota that remain before you hit your request limit. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

ratelimit-reset integer

The time when the oldest request will expire. The value is given in Unix epoch time. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

id string required
Example: not_found

A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."

message string required
Example: The resource you were accessing could not be found.

A message providing additional information about the error, including details to help resolve it when possible.

request_id string optional
Example: 4d9d8375-3c56-4925-a3e7-eb137fed17e9

Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

429

The API rate limit has been exceeded.

ratelimit-limit integer

The default limit on number of requests that can be made per hour and per minute. Current rate limits are 5000 requests per hour and 250 requests per minute.

ratelimit-remaining integer

The number of requests in your hourly quota that remain before you hit your request limit. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

ratelimit-reset integer

The time when the oldest request will expire. The value is given in Unix epoch time. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

id string required
Example: not_found

A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."

message string required
Example: The resource you were accessing could not be found.

A message providing additional information about the error, including details to help resolve it when possible.

request_id string optional
Example: 4d9d8375-3c56-4925-a3e7-eb137fed17e9

Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

500

There was a server error.

ratelimit-limit integer

The default limit on number of requests that can be made per hour and per minute. Current rate limits are 5000 requests per hour and 250 requests per minute.

ratelimit-remaining integer

The number of requests in your hourly quota that remain before you hit your request limit. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

ratelimit-reset integer

The time when the oldest request will expire. The value is given in Unix epoch time. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

id string required
Example: not_found

A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."

message string required
Example: The resource you were accessing could not be found.

A message providing additional information about the error, including details to help resolve it when possible.

request_id string optional
Example: 4d9d8375-3c56-4925-a3e7-eb137fed17e9

Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

default

There was an unexpected error.

ratelimit-limit integer

The default limit on number of requests that can be made per hour and per minute. Current rate limits are 5000 requests per hour and 250 requests per minute.

ratelimit-remaining integer

The number of requests in your hourly quota that remain before you hit your request limit. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

ratelimit-reset integer

The time when the oldest request will expire. The value is given in Unix epoch time. See https://docs.digitalocean.com/reference/api/reference/#rate-limit for information about how requests expire.

id string required
Example: not_found

A short identifier corresponding to the HTTP status code returned. For example, the ID for a response returning a 404 status code would be "not_found."

message string required
Example: The resource you were accessing could not be found.

A message providing additional information about the error, including details to help resolve it when possible.

request_id string optional
Example: 4d9d8375-3c56-4925-a3e7-eb137fed17e9

Optionally, some endpoints may include a request ID that should be provided when reporting bugs or opening support tickets to help identify the issue.

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0
    }
  ],
  "created": 1677649420,
  "id": "chatcmpl-abc123",
  "model": "llama3-8b-instruct",
  "object": "chat.completion",
  "usage": {
    "cache_created_input_tokens": 0,
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "completion_tokens": 20,
    "prompt_tokens": 10,
    "total_tokens": 30
  }
}
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}
{
  "id": "too_many_requests",
  "message": "API rate limit exceeded."
}
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}
{
  "id": "example_error",
  "message": "some error message"
}

We can't find any results for your search.

Try using different keywords or simplifying your search terms.