Skip to main content

Aleph Alpha Client

License PyPI version Documentation Status

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 Open In Colab
2 Simple completion Template 2 Open In Colab
3 Simple search Template 3 Open In Colab
4 Symmetric and Asymmetric Search Template 4 Open In Colab
5 Hidden Embeddings Template 5 Open In Colab
6 Task-specific Endpoints Template 6 Open In Colab

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 pytest or, uv run pytest -k <test_name> to run a specific test
  • typecheck the code and tests using uv run mypy aleph_alpha_client resp. uv run mypy tests
  • format the code using uv run ruff

Releasing a new version

  1. Bump the version in pyproject.toml.
  2. Edit Changelog.md.
  3. Push and merge.
  4. 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

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)

Source distribution for aleph-alpha-client 11.5.1
File Size Uploaded
aleph_alpha_client-11.5.1.tar.gz 53.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aleph-alpha-client 11.5.1
File Interpreter ABI Platform
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}

Release history Release notifications | RSS feed

This release

11.5.1 This release

2 release files

11.5.0

2 release files

11.2.0

2 release files

10.6.2

2 release files

10.6.1

2 release files

10.6.0

2 release files

10.5.1

2 release files

10.5.0

2 release files

10.4.0

2 release files

10.2.2

2 release files

10.2.1

2 release files

10.1.0

2 release files

10.0.1

2 release files

10.0.0

2 release files

9.1.0

2 release files

9.0.0

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.6.0

2 release files

7.5.1

2 release files

7.5.0

2 release files

7.4.0

2 release files

7.3.0

2 release files

7.1.0

2 release files

7.0.1

2 release files

7.0.0

2 release files

6.0.0

2 release files

5.0.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.5.1

2 release files

3.5.0

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.0

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.17.0

2 release files

2.16.0

2 release files

2.15.0

2 release files

2.14.0

2 release files

2.13.0

2 release files

2.12.0

2 release files

2.11.1

2 release files

2.11.0

2 release files

2.9.2

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.1

2 release files

2.8.0

2 release files

2.7.1

2 release files

2.7.0

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.4

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page