@devries-cameron20 / composio Mirror · read-only / commits / 454a53759
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 06:00 UTC

fix(python): clarify missing API key recovery

Brendan O'Leary committed Nov 4, 2026 at 20:59 UTC 454a537590c6021e0f4500b2bec1cb00242a2745
3 files changed +31 -9
python/README.md
+17 -1
@@ -14,7 +14,7 @@ Composio gives your AI agents 1000+ pre-authenticated toolkits, per-user session
14 - [Documentation](https://docs.composio.dev)
15 - [Quickstart](https://docs.composio.dev/docs/quickstart)
16 - [Changelog](https://docs.composio.dev/reference/changelog)
17 -- [Dashboard](https://dashboard.composio.dev) (grab your `COMPOSIO_API_KEY` from [Settings](https://dashboard.composio.dev/settings))
17 +- [Dashboard](https://dashboard.composio.dev) (project keys: Settings > API Keys)
18
19 ## Install
20
@@ -24,6 +24,22 @@ Requires Python 3.11 through 3.15.
24 pip install composio
25 ```
26
27 +## Configure your API key
28 +
29 +Get a project API key from your project's **Settings > API Keys** in the dashboard. The [quickstart](https://docs.composio.dev/docs/quickstart) shows the setup.
30 +
31 +Set the key in the shell that starts your application:
32 +
33 +```bash
34 +export COMPOSIO_API_KEY="your_composio_api_key"
35 +```
36 +
37 +`Composio()` reads `COMPOSIO_API_KEY`. You can instead load the key from your secret store and pass it with `Composio(api_key=project_api_key)`. Keep keys out of source control and logs.
38 +
39 +Without a project key, `Composio()` raises `ApiKeyNotProvidedError` before making API requests. Passing `api_key=None` or `api_key=""` explicitly does not fall back to the environment.
40 +
41 +The CLI is optional and installed separately. `pip install composio` provides neither a `composio` executable nor a `python -m composio` entry point. If you want to use `composio login`, follow the [CLI installation instructions](https://docs.composio.dev/docs/cli#install). CLI login alone does not configure your application's API key; you still need to set `COMPOSIO_API_KEY` or pass `api_key`.
42 +
43 ## Quickstart
44
45 Create a session for one of your users and hand its tools to your agent:
python/composio/exceptions.py
+7 -3
@@ -322,9 +322,13 @@ class ApiKeyNotProvidedError(ApiKeyError, NotFoundError):
322 def __init__(self) -> None:
323 super().__init__(
324 message=(
325 - "API Key not provided, either provide API key "
326 - f"or export it as `{ENV_COMPOSIO_API_KEY}` "
327 - "or run `composio login`"
325 + f"API key not provided. Set `{ENV_COMPOSIO_API_KEY}` or pass "
326 + "`api_key` to `Composio(api_key=...)`. Get a project API key "
327 + "from your project's Settings > API Keys: "
328 + "https://docs.composio.dev/docs/quickstart. "
329 + "Optional: `composio login` requires installing the CLI separately "
330 + "(https://docs.composio.dev/docs/cli#install). CLI login alone "
331 + f"does not set `{ENV_COMPOSIO_API_KEY}` for your application."
332 ),
333 )
334
python/tests/test_sdk.py
+7 -5
@@ -18,17 +18,19 @@ from composio.core.provider._openai import OpenAIProvider
18 class TestComposioSDK:
19 """Test cases for Composio SDK."""
20
21 - def test_sdk_requires_api_key(self):
22 - """Test that SDK requires an API key."""
21 + @pytest.mark.parametrize("config", [{}, {"api_key": None}, {"api_key": ""}])
22 + def test_sdk_requires_api_key(self, config):
23 + """Missing credentials must fail, not create an unauthenticated client."""
24 with patch.dict(os.environ, {}, clear=True):
25 with pytest.raises(exceptions.ApiKeyNotProvidedError):
25 - Composio()
26 + Composio(**config)
27
27 - def test_sdk_explicit_none_api_key_does_not_fall_back_to_env(self):
28 + @pytest.mark.parametrize("api_key", [None, ""])
29 + def test_sdk_explicit_missing_api_key_does_not_fall_back_to_env(self, api_key):
30 """Only an omitted ``api_key`` falls back to COMPOSIO_API_KEY."""
31 with patch.dict(os.environ, {"COMPOSIO_API_KEY": "test-key"}):
32 with pytest.raises(exceptions.ApiKeyNotProvidedError):
31 - Composio(api_key=None)
33 + Composio(api_key=api_key)
34
35 def test_sdk_forwards_user_and_org_api_keys_to_client(self):
36 """User and org keys reach the API client, which selects them per operation."""