
Llama API Python
https://github.com/meta-llama/llama-api-python- Category
- AI Tools
- Rank
- No. 969Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- meta-llama
- GitHub
- 64 stars
- Latest release
- v0.6.0
- Date
About
Official Python library for the Llama API from Meta. Connect to hosted Llama models with the same ergonomics as openai-python.
What it does
A typed Python client that turns Llama REST requests into regular synchronous or asynchronous application code. It handles chat completions, model access, uploads, moderation, Server-Sent Event streaming, response parsing, authentication, retries, timeouts, and API-specific errors.
Why it's ranked here
The case is strong for Python teams consuming the documented service. Both execution styles expose matching capabilities, request and response types improve editor feedback, and transport behavior is configurable. The generated design is practical, though its ten-minute default timeout and automatic retries deserve deliberate production settings.
What's good
Typed dictionaries describe nested request data, while Pydantic models represent responses and support JSON or dictionary conversion. Streaming works in synchronous and asynchronous programs. Uploads accept bytes, paths, or detailed tuples. Status-specific exceptions separate authentication, rate limiting, validation, server, timeout, and connection failures.
Tradeoffs
The default timeout is ten minutes, and timed-out requests are retried twice unless configured otherwise. That can extend failure latency. Response models depend on Pydantic, while networking brings several runtime dependencies. Query serialization does not support indexed arrays, and query parsing lacks custom format syntax.
How to use it well
Use it in Python services, scripts, or workers that call the documented Llama REST API and benefit from typed payloads, streaming, uploads, or asynchronous concurrency. Set explicit timeout and retry policies, keep credentials outside source control, and choose the optional aiohttp backend for concurrency needs. It does not provide model hosting or local inference.
Technical notes+
pyproject.toml defines a Hatchling-built llama_api_client package for Python 3.9+, with httpx, Pydantic, AnyIO, typing extensions, distro, and sniffio dependencies plus an aiohttp extra. src/llama_api_client/_client.py implements LlamaAPIClient and AsyncLlamaAPIClient, Bearer authentication, resource access, configurable base URLs, and status-specific exception mapping. src/llama_api_client/_constants.py sets a 600-second timeout, five-second connect timeout, two retries, and connection-pool limits. src/llama_api_client/_streaming.py decodes synchronous and asynchronous SSE streams and closes responses after iteration. src/llama_api_client/_files.py converts paths and tuples into httpx upload forms, using AnyIO for asynchronous path reads. src/llama_api_client/_qs.py supports comma, repeated, and bracket array encoding but raises for indexed arrays; its parser notes that custom syntax is unsupported.
Observed
- License
- MIT
- Primary language
- Python
- Installation
- Published package installed with pip as llama-api-client
- Packaging
- Hatchling build backend with wheel and source distribution targets
- Interface
- Synchronous and asynchronous Python library for a REST API, including SSE streaming
- Python support
- Python 3.9 or newer
- Platform support
- Classified as OS independent, with POSIX, macOS, Linux, and Windows classifiers
Read from README.md, pyproject.toml, src/llama_api_client/_qs.py, src/llama_api_client/_files.py, src/llama_api_client/_types.py, src/llama_api_client/_client.py, src/llama_api_client/_compat.py, src/llama_api_client/_models.py, src/llama_api_client/__init__.py, src/llama_api_client/_version.py, src/llama_api_client/_resource.py, src/llama_api_client/_response.py, src/llama_api_client/_wrappers.py, src/llama_api_client/_constants.py, src/llama_api_client/_streaming.py.
What it can do
Generate text responses from natural language prompts
Text prompts or questions → AI-generated text responses
Execute conversational AI interactions
Chat messages or dialogue → Contextual AI responses
Process text completion requests
Partial text or prompts → Completed text content
Connect to hosted Llama models
API credentials and configuration → Authenticated connection to Llama services
Send API requests to Meta's Llama models
Structured API calls with parameters → Model responses and metadata
Handle model parameters and settings
Configuration parameters (temperature, max tokens, etc.) → Customized model behavior and responses
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.