Minimal Python SDK for AnalogAI completion endpoints
Project description
AnalogAI SDK (minimal)
Tiny Python client for the Deepthink OpenAI-compatible chat server
(analogai.deepthink.chat). It calls POST {CHAT_BASE_URL}/v1/chat/completions
— a stateful endpoint: memory tenancy is keyed by user_id + agent_id
(both created server-side on first use), Deepthink memory is retrieved per
turn, and messages are ingested in the background.
The return types follow the OpenAI Python SDK schema exactly, so migrating a script is a one-line client swap:
completion = client.generate_completion("hi")
print(completion.choices[0].message.content)
print(completion.usage.prompt_tokens, completion.usage.completion_tokens)
Install
pip install analogaisdk
Setup
Set environment variables in .env:
CHAT_BASE_URL(defaulthttps://cloud.analogai.net:8010; set tohttp://localhost:8010for a local server)ANALOGAI_API_KEY(optional, if your server requires auth)ANALOGAI_MODEL(optional; server default is used when omitted)
Non-streaming
Returns a ChatCompletion matching the OpenAI response shape.
from analogaisdk import AnalogAIClient
client = AnalogAIClient(agent_id="my-agent", user_id="my-user")
completion = client.generate_completion("are humans mortal?")
print(completion.choices[0].message.content)
print("prompt_tokens =", completion.usage.prompt_tokens)
print("completion_tokens=", completion.usage.completion_tokens)
print("total_tokens =", completion.usage.total_tokens)
Streaming
Yields ChatCompletionChunk objects. The final chunk carries usage
with token counts (the SDK sends stream_options={"include_usage": true}
automatically).
for chunk in client.generate_streaming_completion("are humans mortal?"):
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if chunk.usage is not None:
print()
print(chunk.usage.prompt_tokens, chunk.usage.completion_tokens)
Working memory
Working memory (a string or list of strings) is appended to the LLM system prompt alongside the Deepthink memory:
client.generate_completion(
"is Socrates mortal?",
working_memory=["Socrates is a human"],
)
Explicit messages and model
client.generate_completion(
messages=[
{"role": "user", "content": "Say hello"},
],
model="azure:gpt-5.4-mini", # optional, provider-prefixed
temperature=0.2,
)
Response schema
ChatCompletion.id / object / created / modelChatCompletion.choices[i].index / .finish_reasonChatCompletion.choices[i].message.role / .content / .tool_callsChatCompletion.usage.prompt_tokens / .completion_tokens / .total_tokensChatCompletion.raw— the parsed JSON body from the server, unchanged
For streaming:
ChatCompletionChunk.choices[i].delta.role / .content / .tool_callsChatCompletionChunk.choices[i].finish_reasonChatCompletionChunk.usage—Noneon intermediate chunks, populated on the final chunk when the server honoursstream_options.include_usage.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file analogaisdk-0.6.0.tar.gz.
File metadata
- Download URL: analogaisdk-0.6.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.5 Darwin/23.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fcf9bd5b9630fec826cea86bae37b4f06c4d7b0d2f8c10dbdee91713dbb079d
|
|
| MD5 |
fcf0d6e837b78d1f8d335d7099b4830c
|
|
| BLAKE2b-256 |
a99360cc979e7f166046973ca4b0c28668ea88489719a934c1ef1ae0a74e1fcd
|
File details
Details for the file analogaisdk-0.6.0-py3-none-any.whl.
File metadata
- Download URL: analogaisdk-0.6.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.5 Darwin/23.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a1e2ece16374c89c2b8e1838f6038328a6c054cd01072d73c329078c2271315
|
|
| MD5 |
8a80fe58aab07c60e07eb36a8def7a2e
|
|
| BLAKE2b-256 |
5fa768bd000ca8e91a33c07ac528d664ae4091873b60491d4c83d4b4ba64fefb
|