> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Introdução

## Instalação

Você pode interagir com a API por solicitações HTTP ou WebSocket em qualquer linguagem, usando nossas integrações oficiais para Python ou nossas bibliotecas oficiais para Node.js.

Para instalar as integrações oficiais para Python, execute o seguinte comando:

```bash
pip install elevenlabs
```

Para instalar a biblioteca oficial para Node.js, execute o seguinte comando no diretório do seu projeto Node.js:

```bash
npm install @elevenlabs/elevenlabs-js
```

## Acompanhamento dos custos de geração

Acesse os cabeçalhos de resposta para recuperar metadados de geração, incluindo os custos por caractere.

#### Python

```python
from elevenlabs.client import ElevenLabs

client = ElevenLabs(api_key="your_api_key")

# Get raw response with headers
response = client.text_to_speech.with_raw_response.convert(
    text="Hello, world!",
    voice_id="voice_id"
)

# Access character cost from headers
char_cost = response.headers.get("character-cost")

# Optionally store these for debugging
request_id = response.headers.get("request-id")
trace_id = response.headers.get("x-trace-id")

audio_data = response.data
```

#### JavaScript

```typescript
import { ElevenLabsClient } from '@elevenlabs/elevenlabs-js';

const client = new ElevenLabsClient({ apiKey: 'your_api_key' });

// Get raw response with headers
const { data, rawResponse } = await client.textToSpeech
  .convert('voice_id', {
    text: 'Hello, world!',
    modelId: 'eleven_v4',
  })
  .withRawResponse();

// Access character cost from headers
const charCost = rawResponse.headers.get('character-cost');

// Optionally store these for debugging
const requestId = rawResponse.headers.get('request-id');
const traceId = rawResponse.headers.get('x-trace-id');

const audioData = data;
```

A resposta bruta permite acessar:

* Dados da resposta - O conteúdo real da resposta da API
* Cabeçalhos HTTP - Metadados, incluindo custos por caractere e IDs de solicitação