> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Responses

# Responses

Response types returned by the Gateway methods.

## CompleteChatHandlerResponseType

Returned by `gateway.completeChat()`.

```typescript theme={null}
{
  response: MessageType,   // The assistant's response message
  usage: {
    promptTokens: number,
    completionTokens: number,
    totalTokens: number,
  },
  toolCalls?: ToolCallType[],  // If the model requested tool calls
}
```

### Fields

<ParamField body="response" type="MessageType" required>
  The assistant's response message. See [Message Types](/docs/reference/gateway/v2/types/messages).
</ParamField>

<ParamField body="usage" type="object" required>
  Token usage statistics.

  <Expandable title="Properties">
    <ParamField body="promptTokens" type="number">Input tokens used.</ParamField>
    <ParamField body="completionTokens" type="number">Output tokens generated.</ParamField>
    <ParamField body="totalTokens" type="number">Total tokens (input + output).</ParamField>
  </Expandable>
</ParamField>

<ParamField body="toolCalls" type="ToolCallType[]" optional>
  Tool calls requested by the model. Pass these to `gateway.getToolResponses()` to execute them.
</ParamField>

## StreamChatHandlerResponseType

Yielded by the async generator from `gateway.streamChat()`.

```typescript theme={null}
{
  response: string,    // The text chunk
  usage?: {            // Only present in the final chunk
    promptTokens: number,
    completionTokens: number,
    totalTokens: number,
  },
  toolCalls?: ToolCallType[],  // Only present in the final chunk
}
```

## GetEmbeddingsHandlerResponseType

Returned by `gateway.getEmbeddings()`.

```typescript theme={null}
{
  embeddings: number[][],  // Array of embedding vectors
  usage: {
    promptTokens: number,
    totalTokens: number,
  },
}
```

## GatewayError

The error class thrown by all Gateway methods.

```typescript theme={null}
import { GatewayError } from "@adaline/gateway";

try {
  const response = await gateway.completeChat({ ... });
} catch (error) {
  if (error instanceof GatewayError) {
    console.error(error.message);
    console.error(error.cause);   // Original provider error
  }
}
```
