Skip to main content
CoreApiProvider is the low-level HTTP client used by Chat and IllaSDK.

Constructor

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

sendMessage(
  body: CoreApiChatRequest['body'],
  options?: {
    signal?: AbortSignal
    onRequestId?: (requestId: string) => void
  },
): Promise<CoreApiChatResponse>
Sends a non-streaming chat request.

sendMessageStreaming

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

awaitTransaction(
  params: LongPollingActionRequest['params'],
  options?: { signal?: AbortSignal },
): Promise<LongPollingActionResponse>
Checks action status via /api/v1/actions/check.

getRoutes

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

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
  },
)