Skip to main content
The send() method is used to make non-streaming chat completion requests to the Edgee AI Gateway. It returns a SendResponse object with the model’s response.

Arguments

Input Types

String Input

When input is a string, it’s automatically converted to a user message:

InputObject or Dictionary

When input is an InputObject or dictionary, you have full control over the conversation: Example with Dictionary Input:
Example with Tags:

Message Object

Each message in the messages array has the following structure:

Message Roles

  • system: System instructions that set the behavior of the assistant
  • developer: Instructions provided by the application developer, prioritized ahead of user messages.
  • user: Instructions provided by an end user.
  • assistant: Assistant responses (can include tool_calls)
  • tool: Results from tool/function calls (requires tool_call_id)
Example - System and User Messages:
For complete tool calling examples and best practices, see Tools documentation.

Return Value

The send() method returns a SendResponse object when stream=False (default):

SendResponse Object

Choice Object

Each choice in the choices array contains: Example - Handling Multiple Choices:

Message Object (in Response)

The message in each choice has:

Usage Object

Token usage information (when available): Example - Accessing Token Usage:

Compression Object

Token compression metrics (when compression is applied): Example - Accessing Compression Metrics:
The compression object is only present when token compression is applied to the request. Simple queries may not trigger compression.

Convenience Properties

The SendResponse class provides convenience properties for easier access: Example - Using Convenience Properties:

Streaming with send()

You can use send() with stream=True to get streaming responses. This returns a generator yielding StreamChunk objects:
For more details about streaming, see the Stream Method documentation.

Error Handling

The send() method can raise exceptions in several scenarios:

Common Errors

  • API errors: RuntimeError: API error {status}: {message} - The API returned an error status
  • Network errors: Standard HTTP errors from urllib
  • Invalid input: Errors from invalid request structure