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

# Instalacion

> Como instalar y configurar el SDK de Thaliq

## Instalar el paquete

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install @thaliq/sdk
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add @thaliq/sdk
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add @thaliq/sdk
    ```
  </Tab>
</Tabs>

## Quick Start

### 1. Inicializar el SDK

```typescript theme={null}
import { Thaliq } from '@thaliq/sdk';

const thaliq = new Thaliq({
  apiKey: 'tq_live_TU_API_KEY',
});
```

### 2. Enviar un mensaje (sin streaming)

```typescript theme={null}
const response = await thaliq.agent.chat('Hola, ¿que puedes hacer?');
console.log(response.message);
```

### 3. Enviar un mensaje (con streaming)

```typescript theme={null}
const stream = thaliq.agent.stream('Analiza las ventas del Q4');

for await (const event of stream) {
  switch (event.type) {
    case 'content.delta':
      process.stdout.write(event.delta);
      break;
    case 'tool.start':
      console.log(`Ejecutando: ${event.tool}`);
      break;
  }
}
```

### 4. Identificar un usuario (opcional)

Si tu app tiene usuarios autenticados y necesitan acceder a tools protegidas:

```typescript theme={null}
thaliq.identify({
  userId: 'usr_123',
  name: 'Maria Garcia',
  token: 'jwt_del_usuario',
});
```

## Configuracion

```typescript theme={null}
const thaliq = new Thaliq({
  // Requerido
  apiKey: 'tq_live_xxx',

  // Opcionales
  baseUrl: 'https://api.thaliq.com',  // URL de la API
  timeout: 30000,                      // Timeout en ms (default: 30s)
  maxRetries: 2,                       // Reintentos automaticos (default: 2)
  integrationType: 'sdk',              // 'sdk' | 'widget' (default: 'sdk')
  defaultHeaders: {                    // Headers adicionales en cada request
    'X-Custom-Header': 'valor',
  },
});
```

Ver la [referencia completa de configuracion](/sdk/configuration) para todas las opciones.

<Note>
  El SDK funciona en todos los planes. Los limites de resoluciones, agentes, modelos disponibles, RAG y MCP varian segun el plan — ver [Planes y limites](/introduction/plans).
</Note>

## Siguiente paso

<CardGroup cols={2}>
  <Card title="Streaming" icon="bolt" href="/sdk/streaming">
    Aprende a consumir respuestas en tiempo real con 12 tipos de eventos.
  </Card>

  <Card title="Identidad de usuario" icon="user-shield" href="/sdk/user-identity">
    Configura autenticacion para tools protegidas.
  </Card>

  <Card title="Human-in-the-Loop" icon="hand-pointer" href="/sdk/hitl">
    Maneja acciones interactivas (consent, confirm, select, form).
  </Card>

  <Card title="Feedback e Insights" icon="thumbs-up" href="/sdk/feedback">
    Califica respuestas y consume insights extraidos.
  </Card>
</CardGroup>
