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[llama-api]==2.1.0"
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents==0.3.1

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 import LLM, Provider

model = LLM(
    provider=Provider.LLAMA_API,
    model=os.environ["LLAMA_API_MODEL_ID"],
    api_key=os.environ["LLAMA_API_KEY"],
    temperature=0.2,
)
agent = Agent(
    model=model,
    system_prompt="You are a concise assistant.",
)
result = agent("Summarize what an AI agent is in two sentences.")
print(result)

Copyright © 2026 elsai foundry.