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.
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,
)
print(response.text) # typed ChatCompletion response
print(response.usage) # token usage when available
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.text)
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
Pass raw=True on any resource method to get the original JSON dict instead of typed models.
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"])
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, ChatCompletion
client = PawaAI()
try:
completion: ChatCompletion = 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pawa_ai-0.2.0.tar.gz.
File metadata
- Download URL: pawa_ai-0.2.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f70bca605b53559b0843126bc7f3360c75a8e1bbde781afccd2c3acaae88ef9
|
|
| MD5 |
c439bd5aa5ca4c233a05585816c8b45a
|
|
| BLAKE2b-256 |
d78687ee9dbd257e8ffbad119986996f1c68a2aa4e0193d3b329403115f3d458
|
Provenance
The following attestation bundles were made for pawa_ai-0.2.0.tar.gz:
Publisher:
publish.yml on Sartify/pawa-ai-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pawa_ai-0.2.0.tar.gz -
Subject digest:
9f70bca605b53559b0843126bc7f3360c75a8e1bbde781afccd2c3acaae88ef9 - Sigstore transparency entry: 2571634313
- Sigstore integration time:
-
Permalink:
Sartify/pawa-ai-python@40e74af8c00e448cdb098992ecf87edf9cb166b6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sartify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40e74af8c00e448cdb098992ecf87edf9cb166b6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pawa_ai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pawa_ai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
297a9594573766315fd1b5946a84859744030e8ab4afaaee97e036edbea95e38
|
|
| MD5 |
a010cf3a24b59a6c848c38bb5000ae84
|
|
| BLAKE2b-256 |
e13b674d777a8323ba2f2517edcb380a0645c9081f22e28f796b6abe80398805
|
Provenance
The following attestation bundles were made for pawa_ai-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Sartify/pawa-ai-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pawa_ai-0.2.0-py3-none-any.whl -
Subject digest:
297a9594573766315fd1b5946a84859744030e8ab4afaaee97e036edbea95e38 - Sigstore transparency entry: 2571634333
- Sigstore integration time:
-
Permalink:
Sartify/pawa-ai-python@40e74af8c00e448cdb098992ecf87edf9cb166b6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sartify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40e74af8c00e448cdb098992ecf87edf9cb166b6 -
Trigger Event:
workflow_dispatch
-
Statement type: