> ## Documentation Index
> Fetch the complete documentation index at: https://thethirdpenco-feat-tool-lifecycle-events.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Meta Llama

> Use Meta Llama models via the official API

Meta Llama provides access to the official Llama models through an OpenAI-compatible API.

## Setup

Set your API key as an environment variable:

```bash theme={null}
export LLAMA_API_KEY="la-..."
```

Get your API key from [Meta Llama](https://www.llama.com/).

## Usage

```python theme={null}
from ai_query import generate_text
from ai_query.providers import llama

result = await generate_text(
    model=llama("llama-3.1-70b-instruct"),
    prompt="Explain quantum computing."
)
```

## Available Models

| Model ID                        | Description                            |
| ------------------------------- | -------------------------------------- |
| `llama-3.1-405b-instruct`       | Llama 3.1 405B - Frontier intelligence |
| `llama-3.1-70b-instruct`        | Llama 3.1 70B - High performance       |
| `llama-3.1-8b-instruct`         | Llama 3.1 8B - Fast and lightweight    |
| `llama-3.2-90b-vision-instruct` | Llama 3.2 90B - Vision capable         |
| `llama-3.2-11b-vision-instruct` | Llama 3.2 11B - Vision capable         |

See the [Llama API docs](https://llama.developer.meta.com/docs/models) for model details.

## Provider Options

Customize parameters:

```python theme={null}
result = await generate_text(
    model=llama("llama-3.1-70b-instruct"),
    prompt="Write a story.",
    provider_options={
        "llama": {
            "temperature": 0.9,
            "max_tokens": 1000
        }
    }
)
```

## Tool Calling

Tool calling works standardly:

```python theme={null}
from ai_query import generate_text
from ai_query.providers import llama, tool, Field

@tool(description="Get stock price")
async def get_stock(symbol: str = Field(description="Stock symbol")) -> str:
    return f"{symbol}: $150.00"

result = await generate_text(
    model=llama("llama-3.1-70b-instruct"),
    prompt="What is the price of AAPL?",
    tools={"get_stock": get_stock}
)
```

## Streaming

```python theme={null}
from ai_query import stream_text
from ai_query.providers import llama

result = stream_text(
    model=llama("llama-3.1-70b-instruct"),
    prompt="Write a song."
)

async for chunk in result.text_stream:
    print(chunk, end="", flush=True)
```
