cognicloud
Use CogniCloud from Python. Version 0.4.0 covers browser sessions for agents; the other products come later. Same behaviour as @cognicloud/sdk and cognicloud-sdk.
Install
Python 3.10 or newer. No dependencies.
pip install "git+https://github.com/Flippico/cognicloud-python-sdk.git"
Browser sessions
Browser calls accept the signed-in person's token, or a browser key. Create a key in the dashboard under Browser → API keys and pass it as the token. A key keeps working after its owner signs out. Keys cannot be created through the SDK or the API.
Use the browser product with a browser key alone. The key names its workspace, so no Amadeus token or tenant is needed:
import os
from cognicloud import CogniCloudBrowser
browser = CogniCloudBrowser(os.environ["COGNICLOUD_BROWSER_KEY"])
session = browser.browser.sessions.create(timeout_minutes=15)
from cognicloud import CogniCloud
cc = CogniCloud(amadeus_token)
session = cc.browser.sessions.create(timeout_minutes=15)
print(session.cdp_url) # connect Playwright, Puppeteer or any CDP client here
cc.browser.sessions.stop(session.id)
timeout_minutesis 1 to 240 and defaults to 15.- Closing the CDP connection does not stop a session; call
sessions.stop. statusisactiveorstopped;cdp_urlandlive_urlareNoneonce stopped.live_urlis a page where a person can watch and take over the browser.sessions.list()returnsitemsandconcurrency(active,limit). A start beyond the limit raisesCogniCloudErrorwithstatus == 429andcode == "concurrency_limit".- Proxy countries, profiles, screen sizes, captcha solving and recording are not available yet.
browser.countries()andbrowser.profiles()return empty lists.
Call an endpoint
import os
from cognicloud import EndpointClient, ResponsesRequest, McpTool, EmbeddingsRequest, DeltaEvent, DoneEvent, ErrorEvent
endpoint = EndpointClient(os.environ["COGNICLOUD_KEY"], endpoint_id=os.environ["COGNICLOUD_ENDPOINT_ID"])
answer = endpoint.responses(
ResponsesRequest(
input="Is this invoice valid?",
instructions="Check invoices.",
tools=[McpTool("ksef", allowed_tools=["validate_invoice_xml"])],
tool_choice="required",
)
)
next_answer = endpoint.responses(ResponsesRequest("And this one?", previous_response_id=answer.response_id))
vectors = endpoint.embeddings(EmbeddingsRequest(["first text", "second text"], dimensions=256))
McpTool names an MCP server with server_url and bearer_token. The gateway checks the address (https, with no credentials or fragment) and passes both to the provider. A tool with only server_label names a server the gateway is configured with. The answer's response_id continues the conversation on the same endpoint, and output_items holds the tool calls. embeddings needs an endpoint whose deployment is an embedding model, and returns one vector per input.
Streaming
for event in endpoint.stream({"messages": [{"role": "user", "content": "Write a haiku."}]}):
if isinstance(event, DeltaEvent):
print(event.text, end="")
elif isinstance(event, DoneEvent):
print(f"\n{event.answer.usage.total_tokens} tokens")
elif isinstance(event, ErrorEvent):
print(f"{event.code}: {event.message}")
ResponsesRequest(extra={...}) sends any other field to the provider unchanged, such as seed or reasoning. The gateway refuses the fields it sets itself, such as n or store.
stream opens the call before it returns, so a refusal raises immediately, before any event. Each event is a DeltaEvent (text), then one DoneEvent (answer), or one ErrorEvent (code, message). Streams are not retried and have no total timeout; the gateway ends them at five minutes. Stop early by closing the iterator; the gateway still settles the call.
Errors
Every failed request raises CogniCloudError with status (the HTTP status, 0 when no answer came back), code (CogniCloud's stable error code, or a local one such as timeout or network_error) and message.
Configuration
| Option | Default | |
|---|---|---|
token |
required | The account the calls act as: the signed-in person's Amadeus session token, or a browser key for browser calls. A missing or blank token raises CogniCloudError with code missing_token when the client is created. |
tenant |
"cognicloud" |
The workspace, sent as tenant_id. The platform workspace is open to every signed-in user. |
locale |
"en" |
Accept-Language for localised responses. |
timeout |
30.0 |
Seconds per request. |
max_retries |
2 |
For 429 and 5xx, on reads only. Starts and stops are never retried. |
browser_base_url |
https://cognicloud.flippi.co/api/v1/browser |
Point at another environment. |
Development
PYTHONPATH=src python -m unittest discover -s tests
The tests run against a local HTTP stub and need no network access.
See CHANGELOG.md.
Metadata
Release files for cognicloud 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cognicloud-0.12.0.tar.gz | 15.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cognicloud-0.12.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.2 kB
Release files / cognicloud-0.12.0.tar.gz
| Download URL | cognicloud-0.12.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42c8044c7ab79ee8c5ebb1e6f05c5ed801a3bb13a6bbbc0bb782d594074e7718
|
|
BLAKE2b-256 checksum How to use checksums |
8ccb495fea2cd770453870d44d60439dfc55458f04a0aefc82781394f16b29bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / cognicloud-0.12.0-py3-none-any.whl
| Download URL | cognicloud-0.12.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
646a1b984986d93fd481a05d0362acdfcf351a1b2bc8f37b70469044fb46d88b
|
|
BLAKE2b-256 checksum How to use checksums |
77fff549bd378b782258907b0155845be144701bbca855447e69a8074949e096
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for cognicloud 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.