Skip to main content
The Send() method is used to make chat completion requests to the Edgee AI Gateway.

Arguments

Input Types

The Send() method accept multiple input types:

String Input

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

InputObject

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

Map Input

You can also use a map[string]interface{} for dynamic input:

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 ToolCalls)
  • tool: Results from tool/function calls (requires ToolCallID)
Example - System and User Messages:
For complete tool calling examples and best practices, see Tools documentation.

Return Value

The Send() method returns (SendResponse, error). On success, the SendResponse contains:

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 Methods

The SendResponse struct provides convenience methods for easier access: Example - Using Convenience Methods:

Error Handling

The Send() method return Go errors:

Common Errors

  • API errors: fmt.Errorf("API error %d: %s", statusCode, message) - The API returned an error status
  • Network errors: Standard Go HTTP errors
  • Invalid input: fmt.Errorf("unsupported input type: %T", input) - Invalid request structure
  • JSON errors: Errors from JSON marshaling/unmarshaling