Pawa AI Python SDK
Official Python library for the Pawa AI API.
Pawa AI provides African-built small language models for chat, voice, embeddings, document parsing, agents, and knowledge bases.
Installation
pip install pawa-ai
Quickstart
Set your API key:
export PAWA_AI_API_KEY="your_api_key_here"
Get your key from the Builders Dashboard.
See examples/ for a full walkthrough from pip install to API responses.
Chat
from pawa_ai import PawaAI
client = PawaAI()
response = client.chat.create(
model="pawa-v1-ember-20240924",
messages=[
{
"role": "user",
"content": [{"type": "text", "text": "Hello! How can I use AI in my app?"}],
}
],
stream=False,
)
# Always a dict matching the API JSON
print(response["success"])
print(response["data"]["request"][0]["message"]["content"])
print(response["data"].get("usage"))
Streaming
with client.chat.create(
model="pawa-v1-ember-20240924",
messages=[
{"role": "user", "content": [{"type": "text", "text": "Explain RAG in simple terms"}]}
],
stream=True,
) as stream:
for delta in stream.text_deltas():
print(delta, end="", flush=True)
# Or collect the full response after streaming
completion = stream.collect()
print(completion["data"]["request"][0]["message"]["content"])
Async streaming:
stream = await client.chat.create(..., stream=True)
text = await stream.collect_text()
Text-to-Speech
audio = client.voice.text_to_speech.create(
model="pawa-tts-v1-20250704",
text="Hello, this is Pawa AI speaking!",
voice="liora",
)
with open("output.mp3", "wb") as f:
f.write(audio)
Embeddings
response = client.vectors.create(
model="pawa-embeddings-v1-20241001",
sentences=["Embed this sentence.", "And this one too."],
lang="multi",
)
embeddings = response.embeddings
Retries with exponential backoff
from pawa_ai import PawaAI, RetryConfig
client = PawaAI(
retry_config=RetryConfig(
max_retries=3,
initial_delay=0.5,
max_delay=8.0,
exponential_base=2.0,
jitter=0.1,
)
)
Retries automatically apply to rate limits (429), server errors (500/502/503/504), and connection failures. The SDK respects Retry-After response headers when present.
Async
import asyncio
from pawa_ai import AsyncPawaAI
async def main():
async with AsyncPawaAI() as client:
response = await client.chat.create(
model="pawa-v1-ember-20240924",
messages=[
{"role": "user", "content": [{"type": "text", "text": "Habari yako?"}]}
],
)
print(response["data"]["request"][0]["message"]["content"])
asyncio.run(main())
API coverage
| Resource | Methods |
|---|---|
client.chat |
create, completions |
client.models |
list, retrieve |
client.voice.text_to_speech |
create |
client.voice.speech_to_text |
create, transcribe |
client.vectors |
create, embeddings |
client.documents |
parse |
client.agents |
create, update, delete, list, retrieve |
client.agents.chat |
create |
client.storage.knowledge_base |
CRUD, list_files, semantic_retrieval |
client.transcribe.workspaces |
CRUD, transcription management |
Error handling
from pawa_ai import PawaAI, AuthenticationError, RateLimitError
client = PawaAI()
try:
response = client.chat.create(model="pawa-v1-ember-20240924", messages=[...])
except AuthenticationError as e:
print(f"Auth failed: {e.message}")
except RateLimitError as e:
print(f"Rate limited: {e.status_code}")
Documentation
License
MIT
Metadata
Release files for pawa-ai 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pawa_ai-0.2.1.tar.gz | 13.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pawa_ai-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.3 kB
Release files / pawa_ai-0.2.1.tar.gz
| Download URL | pawa_ai-0.2.1.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0aef3a0f2be23435981cf587523debd362cd3c3d18b25e46d0a9f8c48223b05d
|
|
BLAKE2b-256 checksum How to use checksums |
9b3495ac476b5cc507d7217c6a9d711070131195f4afbca1c9dd9caa0a9b050a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pawa_ai-0.2.1-py3-none-any.whl
| Download URL | pawa_ai-0.2.1-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29c49cb7ee0f944dc99dac310cdb26523cdd838e87a1f302beeed7532254cca0
|
|
BLAKE2b-256 checksum How to use checksums |
56e6324dba4d41784cab95e663a56184b08c21d17374ce5007c50afa6b46afe7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency log