Skip to content

Meta Llama API

Use Meta's hosted Llama models with LlamaAPIModel. Requires the llamaapi optional extra on elsai-model.

For standalone invoke / stream usage, see LLM Models — Meta Llama API.

Install

bash
pip install --extra-index-url https://core-packages.elsai.ai/root/ "elsai-model[llamaapi]==2.0.0"
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents==0.2.0

Setup

  1. Create a Meta Llama API key.
  2. Export credentials and your model ID:
bash
export LLAMA_API_KEY=...
export LLAMA_API_MODEL_ID=Llama-4-Maverick-17B-128E-Instruct-FP8

Agent — basic

python
import os
from elsai import Agent
from elsai_model.llamaapi import LlamaAPIModel

model = LlamaAPIModel(
    model_id=os.environ["LLAMA_API_MODEL_ID"],
    client_args={"api_key": os.environ["LLAMA_API_KEY"]},
    temperature=0.2,
)
agent = Agent(
    model=model,
    system_prompt="You are a concise assistant.",
)
result = agent("What is 17 + 28? Reply with just the number.")
print(result.message["content"][0]["text"])

Copyright © 2026 Elsai Foundry.