{"id":26103707,"url":"https://github.com/aleph-alpha/aleph-alpha-client","last_synced_at":"2025-05-16T04:04:08.072Z","repository":{"id":37084494,"uuid":"375611376","full_name":"Aleph-Alpha/aleph-alpha-client","owner":"Aleph-Alpha","description":"Python Client for the Aleph Alpha API","archived":false,"fork":false,"pushed_at":"2025-05-15T11:18:13.000Z","size":1692,"stargazers_count":95,"open_issues_count":7,"forks_count":21,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-16T04:04:05.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://aleph-alpha-client.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aleph-Alpha.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-10T07:35:38.000Z","updated_at":"2025-05-14T10:46:56.000Z","dependencies_parsed_at":"2023-11-16T16:52:57.435Z","dependency_job_id":"3f07dbc3-4fae-4352-b423-4d48c79d7316","html_url":"https://github.com/Aleph-Alpha/aleph-alpha-client","commit_stats":{"total_commits":360,"total_committers":21,"mean_commits":"17.142857142857142","dds":0.6222222222222222,"last_synced_commit":"2639a576dafa0d9cdd7f01febd560ee29e19466e"},"previous_names":[],"tags_count":87,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aleph-Alpha%2Faleph-alpha-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aleph-Alpha%2Faleph-alpha-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aleph-Alpha%2Faleph-alpha-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aleph-Alpha%2Faleph-alpha-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aleph-Alpha","download_url":"https://codeload.github.com/Aleph-Alpha/aleph-alpha-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-09T20:42:06.555Z","updated_at":"2025-05-16T04:04:08.060Z","avatar_url":"https://github.com/Aleph-Alpha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aleph Alpha Client\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://i.imgur.com/FSM2NNV.png\" width=\"50%\" /\u003e\n\u003c/p\u003e\n\n[![License](https://img.shields.io/crates/l/aleph-alpha-client)](https://github.com/Aleph-Alpha/aleph-alpha-client/blob/main/LICENSE)\n[![PyPI version](https://badge.fury.io/py/aleph-alpha-client.svg)](https://pypi.org/project/aleph-alpha-client/)\n[![Documentation Status](https://readthedocs.org/projects/aleph-alpha-client/badge/?version=latest)](https://aleph-alpha-client.readthedocs.io/en/latest/?badge=latest)\n\nPython client for the [Aleph Alpha](https://aleph-alpha.com) API.\n\n## Usage\n\n### Synchronous Client\n\n```python\nimport os\nfrom aleph_alpha_client import Client, CompletionRequest, Prompt\n\nclient = Client(\n    token=os.environ[\"TEST_TOKEN\"],\n    host=os.environ[\"TEST_API_URL\"],\n)\nrequest = CompletionRequest(\n    prompt=Prompt.from_text(\"Provide a short description of AI:\"),\n    maximum_tokens=64,\n)\nresponse = client.complete(request, model=\"pharia-1-llm-7b-control\")\n\nprint(response.completions[0].completion)\n```\n\n### Asynchronous Client\n\n```python\nimport os\nfrom aleph_alpha_client import AsyncClient, CompletionRequest, Prompt\n\n# Can enter context manager within an async function\nasync with AsyncClient(\n    token=os.environ[\"TEST_TOKEN\"],\n    host=os.environ[\"TEST_API_URL\"],\n) as client:\n    request = CompletionRequest(\n        prompt=Prompt.from_text(\"Provide a short description of AI:\"),\n        maximum_tokens=64,\n    )\n    response = client.complete_with_streaming(request, model=\"pharia-1-llm-7b-control\")\n\n    async for stream_item in response:\n        print(stream_item)\n```\n\n### Interactive Examples\n\nThis table contains interactive code examples, further exercises can be found in the [examples repository](https://github.com/Aleph-Alpha/examples).\n| Template | Description | Internal Link | Colab Link |\n|----------|-------------|---------------| -----------|\n| 1 | Calling the API | [Template 1](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/01_using_client.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/01_using_client.ipynb)|\n| 2 | Simple completion | [Template 2](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/02_prompting.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/02_prompting.ipynb)|\n| 3 | Simple search | [Template 3](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/03_simple_search.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/03_simple_search.ipynb)|\n| 4 | Symmetric and Asymmetric Search | [Template 4](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/04_semantic_search.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/04_semantic_search.ipynb)|\n| 5 | Hidden Embeddings | [Template 5](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/05_hidden_embeddings.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/05_hidden_embeddings.ipynb)|\n| 6 | Task-specific Endpoints | [Template 6](https://github.com/Aleph-Alpha/examples/blob/main/boilerplate/06_task_specific_endpoints.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Aleph-Alpha/examples/blob/main/boilerplate/06_task_specific_endpoints.ipynb)|\n\n## Installation\n\nThe latest stable version is deployed to PyPi so you can install this package via pip/uv:\n\n```sh\nuv add aleph-alpha-client\n```\n\nGet started using the client by first [creating an account](https://app.aleph-alpha.com/signup). Afterwards head over to [your profile](https://app.aleph-alpha.com/profile) to create an API token. Read more about how you can manage your API tokens [here](https://docs.aleph-alpha.com/docs/account).\n\n## Development\n\nFor local development, install the dependencies:\n\n```sh\nuv sync\n```\n\nNow you should be able to ...\n\n* run all the tests using `uv run pytest` or, `uv run pytest -k \u003ctest_name\u003e` to run a specific test\n* typecheck the code and tests using `uv run mypy aleph_alpha_client` resp. `uv run mypy tests`\n* format the code using `uv run ruff`\n\n### Releasing a new version\n\n1. Bump the version in `pyproject.toml`.\n2. Edit `Changelog.md`.\n3. Go to https://github.com/Aleph-Alpha/aleph-alpha-client/releases/new\n   - use the version as tag and release title (e.g. `v10.1.0`)\n   - auto-generate the description based on commit history\n\n## Links\n\n- [HTTP API Docs](https://docs.aleph-alpha.com/products/apis/pharia-inference/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleph-alpha%2Faleph-alpha-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleph-alpha%2Faleph-alpha-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleph-alpha%2Faleph-alpha-client/lists"}