Aleph Alpha Client
Python client for the Aleph Alpha API.
Usage
Synchronous Client
import os
from aleph_alpha_client import Client, CompletionRequest, Prompt
client = Client(
token=os.environ["TEST_TOKEN"],
host=os.environ["TEST_API_URL"],
)
request = CompletionRequest(
prompt=Prompt.from_text("Provide a short description of AI:"),
maximum_tokens=64,
)
response = client.complete(request, model="pharia-1-llm-7b-control")
print(response.completions[0].completion)
Asynchronous Client
import os
from aleph_alpha_client import AsyncClient, CompletionRequest, Prompt
# Can enter context manager within an async function
async with AsyncClient(
token=os.environ["TEST_TOKEN"],
host=os.environ["TEST_API_URL"],
) as client:
request = CompletionRequest(
prompt=Prompt.from_text("Provide a short description of AI:"),
maximum_tokens=64,
)
response = client.complete_with_streaming(request, model="pharia-1-llm-7b-control")
async for stream_item in response:
print(stream_item)
Interactive Examples
This table contains interactive code examples, further exercises can be found in the examples repository.
| Template | Description | Internal Link | Colab Link |
|---|---|---|---|
| 1 | Calling the API | Template 1 | |
| 2 | Simple completion | Template 2 | |
| 3 | Simple search | Template 3 | |
| 4 | Symmetric and Asymmetric Search | Template 4 | |
| 5 | Hidden Embeddings | Template 5 | |
| 6 | Task-specific Endpoints | Template 6 |
Installation
The latest stable version is deployed to PyPi so you can install this package via pip/uv:
uv add aleph-alpha-client
Get started using the client by first creating an account. Afterwards head over to your profile to create an API token. Read more about how you can manage your API tokens here.
Development
For local development, install the dependencies:
uv sync
Now you should be able to ...
- run all the tests using
uv run pytestor,uv run pytest -k <test_name>to run a specific test - typecheck the code and tests using
uv run mypy aleph_alpha_clientresp.uv run mypy tests - format the code using
uv run ruff
Releasing a new version
- Bump the version in
pyproject.toml. - Edit
Changelog.md. - Push and merge.
- Go to https://github.com/Aleph-Alpha/aleph-alpha-client/releases/new
- use the version as tag and release title (e.g.
v10.1.0) - auto-generate the description based on commit history
- use the version as tag and release title (e.g.
Links
Release files for aleph-alpha-client 11.5.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 | |
|---|---|---|---|
| aleph_alpha_client-11.5.1.tar.gz | 53.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aleph_alpha_client-11.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.5 kB
Release files / aleph_alpha_client-11.5.1.tar.gz
| Download URL | aleph_alpha_client-11.5.1.tar.gz |
|---|---|
| Size | 53.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5899c6478bae9dfb7c4a5379fe90ae580be56f5b346fd21e968995485ce5cd7b
|
|
BLAKE2b-256 checksum How to use checksums |
096e77d8264bbf774b343c4c6b3f7b40e06b9e63a02e3010d73f77236f1ee0bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aleph_alpha_client-11.5.1-py3-none-any.whl
| Download URL | aleph_alpha_client-11.5.1-py3-none-any.whl |
|---|---|
| Size | 45.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a7dc5c74e34161bf94cfb1a146cd1d101b8bd7da30d33b835dd85c3d6f73e76
|
|
BLAKE2b-256 checksum How to use checksums |
0c03a2591e54b01f8646b02cee190d3bc3dcfbd073960f6b38824e30d45cb408
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|