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

# CoreApiProvider

> HTTP transport for ILLA's Core API

`CoreApiProvider` is the low-level HTTP client used by `Chat` and `IllaSDK`.

## Constructor

```ts theme={null}
new CoreApiProvider({
  headers: { 'x-api-key': string },
  baseURL?: string,
  timeout?: number,
  routes?: { chat?: string; actionStatus?: string },
  httpClientFactory?: (config) => AxiosInstance,
})
```

Throws `CoreApiAuthenticationMissing` when `x-api-key` is missing.

## Methods

### `sendMessage`

```ts theme={null}
sendMessage(
  body: CoreApiChatRequest['body'],
  options?: {
    signal?: AbortSignal
    onRequestId?: (requestId: string) => void
  },
): Promise<CoreApiChatResponse>
```

Sends a non-streaming chat request.

### `sendMessageStreaming`

```ts theme={null}
sendMessageStreaming(
  body: CoreApiChatRequest['body'],
  options?: {
    signal?: AbortSignal
    onRequestId?: (requestId: string) => void
    onEvent?: (event: TelemetryEvent) => void
    onTextDelta?: (delta: string) => void
    onComplete?: (result: ValidatedResultEventData) => void
    onError?: (error: Error) => void
  },
): Promise<void>
```

Sends a streaming SSE request and emits telemetry/final callbacks.
The canonical streaming path is `POST /api/v1/chat` with `Accept: text/event-stream`.

### `awaitTransaction`

```ts theme={null}
awaitTransaction(
  params: LongPollingActionRequest['params'],
  options?: { signal?: AbortSignal },
): Promise<LongPollingActionResponse>
```

Checks action status via `/api/v1/actions/check`.

### `getRoutes`

```ts theme={null}
getRoutes(): { chat: string; actionStatus: string }
```

Returns resolved route paths.

## Defaults

* `baseURL`: `https://api-dev.illalabs.io`
* `routes.chat`: `/api/v1/chat/`
* `routes.actionStatus`: `/api/v1/actions/check`

## Example

```ts theme={null}
const provider = new CoreApiProvider({
  headers: { 'x-api-key': process.env.ILLA_API_KEY! },
})

const response = await provider.sendMessage(
  {
    userContext: { address: '0x1234...' },
    prompt: {
      role: 'user',
      content: [{ type: 'text', text: 'What is my balance?' }],
    },
    messages: [],
    toolResults: [],
    toolsConfig: {},
    personalityContext: { channel: 'text' },
    // languageModel: configured by ILLA Core
  },
)
```
