Skip to content

feat: add Llama API docs #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/api-reference/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
::: strands.models.ollama
options:
heading_level: 2
::: strands.models.llamaapi
options:
heading_level: 2
69 changes: 69 additions & 0 deletions docs/user-guide/concepts/model-providers/llamaapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Llama API

[Llama API](https://llama.developer.meta.com/) is a Meta-hosted API service that helps you integrate Llama models into your applications quickly and efficiently.

Llama API provides access to Llama models through a simple API interface, with inference provided by Meta, so you can focus on building AI-powered solutions without managing your own inference infrastructure.

With Llama API, you get access to state-of-the-art AI capabilities through a developer-friendly interface designed for simplicity and performance.

## Installation

Llama API is configured as an optional dependency in Strands Agents. To install, run:

```bash
pip install strands-agents[llamaapi]
```

## Usage

After installing `llamaapi`, you can import and initialize Strands Agents' Llama API provider as follows:

```python
from strands import Agent
from strands.models.llamaapi import LlamaAPIModel
from strands_tools import calculator

model = LlamaAPIModel(
client_args={
"api_key": "<KEY>",
},
# **model_config
model_id="Llama-4-Maverick-17B-128E-Instruct-FP8",
)

agent = Agent(model=model, tools=[calculator])
response = agent("What is 2+2")
print(response)
```

## Configuration

### Client Configuration

The `client_args` configure the underlying LlamaAPI client. For a complete list of available arguments, please refer to the LlamaAPI [docs](https://llama.developer.meta.com/docs/).


### Model Configuration

The `model_config` configures the underlying model selected for inference. The supported configurations are:

| Parameter | Description | Example | Options |
|------------|-------------|---------|---------|
| `model_id` | ID of a model to use | `Llama-4-Maverick-17B-128E-Instruct-FP8` | [reference](https://llama.developer.meta.com/docs/)
| `repetition_penalty` | Controls the likelyhood and generating repetitive responses. (minimum: 1, maximum: 2, default: 1) | `1` | [reference](https://llama.developer.meta.com/docs/api/chat)
| `temperature` | Controls randomness of the response by setting a temperature. | `0.7` | [reference](https://llama.developer.meta.com/docs/api/chat)
| `top_p` | Controls diversity of the response by setting a probability threshold when choosing the next token. | `0.9` | [reference](https://llama.developer.meta.com/docs/api/chat)
| `max_completion_tokens` | The maximum number of tokens to generate. | `4096` | [reference](https://llama.developer.meta.com/docs/api/chat)
| `top_k` | Only sample from the top K options for each subsequent token. | `10` | [reference](https://llama.developer.meta.com/docs/api/chat)


## Troubleshooting

### Module Not Found

If you encounter the error `ModuleNotFoundError: No module named 'llamaapi'`, this means you haven't installed the `llamaapi` dependency in your environment. To fix, run `pip install strands-agents[llamaapi]`.

## References

- [API](../../../api-reference/models.md)
- [LlamaAPI](https://llama.developer.meta.com/docs/)
5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ nav:
- Amazon Bedrock: user-guide/concepts/model-providers/amazon-bedrock.md
- LiteLLM: user-guide/concepts/model-providers/litellm.md
- Ollama: user-guide/concepts/model-providers/ollama.md
- LlamaAPI: user-guide/concepts/model-providers/llamaapi.md
- Custom Providers: user-guide/concepts/model-providers/custom_model_provider.md
- Streaming:
- Async Iterators: user-guide/concepts/streaming/async-iterators.md
Expand Down Expand Up @@ -105,7 +106,7 @@ nav:
- Weather Forecaster: examples/python/weather_forecaster.md
- File Operations: examples/python/file_operations.md
- Agents Workflows: examples/python/agents_workflows.md
- Knowledge-Base Workflow: examples/python/knowledge_base_agent.md
- Knowledge-Base Workflow: examples/python/knowledge_base_agent.md
- Multi Agents: examples/python/multi_agent_example/multi_agent_example.md
- Meta Tooling: examples/python/meta_tooling.md
- MCP: examples/python/mcp_calculator.md
Expand Down Expand Up @@ -167,4 +168,4 @@ validation:
not_found: warn
anchors: warn
absolute_links: warn
unrecognized_links: warn
unrecognized_links: warn