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

# Basic Usage

> Basic usage patterns for the Lumina SDK

Common patterns for using the Lumina SDK.

***

## Single LLM Call

```typescript theme={null}
const response = await lumina.traceLLM(
  () =>
    openai.chat.completions.create({
      model: 'gpt-4',
      messages: [{ role: 'user', content: 'Hello!' }],
    }),
  {
    name: 'chat-completion',
    system: 'openai',
    prompt: 'Hello!',
  }
);
```

***

## Adding Metadata

```typescript theme={null}
await lumina.traceLLM(
  () => llm.generate(prompt),
  {
    name: 'chat',
    metadata: {
      userId: 'user-123',
      sessionId: 'session-456',
    },
  }
);
```

***

## Error Handling

```typescript theme={null}
try {
  await lumina.traceLLM(
    () => llm.generate(prompt),
    { name: 'chat' }
  );
} catch (error) {
  // Error automatically recorded
  console.error('LLM call failed:', error);
  throw error;
}
```

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Advanced Usage" href="/docs/sdk/typescript/advanced-usage">
    Multi-span tracing patterns
  </Card>

  <Card title="API Reference" href="/docs/sdk/typescript/api-reference">
    Complete API docs
  </Card>
</CardGroup>
