AstarCloud SDK
Python SDK for the AstarCloud API with support for chat completions, tool calling, and audio transcription.
Installation
pip install astarcloud
Quick Start
from AstarCloud import AstarClient
client = AstarClient(api_key="sk-...")
# Basic chat completion
response = client.create.completion(
messages=[{"role": "user", "content": "Hello!"}],
model="gpt-4.1"
)
print(response.choices[0].message.content)
Tool Calling
The SDK supports tool calling for compatible models (gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, astar-gpt-4.1).
Basic Tool Usage
from AstarCloud import AstarClient, ToolSpec
client = AstarClient(api_key="sk-...")
# Define a tool
weather_tool = ToolSpec(
function={
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
)
# Use the tool in a completion
response = client.create.completion(
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
model="gpt-4.1",
tools=[weather_tool],
tool_choice="auto"
)
# Check if the model wants to call a tool
if response.choices[0].tool_calls:
tool_call = response.choices[0].tool_calls[0]
print(f"Tool called: {tool_call.function['name']}")
print(f"Arguments: {tool_call.function['arguments']}")
Bound Tools Client
For convenience, you can create a client with pre-bound tools:
# Create a client with bound tools
bound_client = client.bind_tools([weather_tool])
# All completions will automatically include the bound tools
response = bound_client.create.completion(
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
model="gpt-4.1"
)
Streaming
The SDK supports streaming responses:
for chunk in client.create.completion(
messages=[{"role": "user", "content": "Write a story"}],
model="gpt-4.1",
stream=True
):
if chunk.choices[0].message.content:
print(chunk.choices[0].message.content, end="")
Audio Transcription
The SDK supports audio transcription with various output formats:
Basic Transcription
# Transcribe an audio file
transcription = client.audio.transcribe(
file_path="path/to/audio.mp3"
)
print(transcription.text)
print(f"Language: {transcription.language}")
print(f"Duration: {transcription.duration} seconds")
Advanced Options
# Transcribe with custom options
transcription = client.audio.transcribe(
file_path="meeting.wav",
model="gpt-4o-transcribe", # or "whisper-1", "gpt-4o-mini-transcribe"
prompt="This is a technical meeting about AI",
temperature=0.2,
response_format="verbose_json" # Get detailed word-level timestamps
)
# Access segments and words (in verbose_json format)
for segment in transcription.segments:
print(f"{segment.start}s - {segment.end}s: {segment.text}")
for word in transcription.words:
print(f"{word.word} ({word.confidence:.2f})")
Output Formats
# Plain text output
text = client.audio.transcribe(
file_path="audio.mp3",
response_format="text" # Returns string directly
)
# SRT subtitles
srt_content = client.audio.transcribe(
file_path="video_audio.mp3",
response_format="srt"
)
# WebVTT subtitles
vtt_content = client.audio.transcribe(
file_path="video_audio.mp3",
response_format="vtt"
)
Supported Audio Formats
- MP3, MP4, MPEG, MPGA, M4A, WAV, WEBM
- Maximum file size: 25MB
Available Transcription Models
whisper-1: Standard Whisper modelgpt-4o-transcribe: Latest GPT-4o transcriptiongpt-4o-mini-transcribe: Faster, cheaper option
Error Handling
from AstarCloud import AstarClient
from AstarCloud._exceptions import APIError, AuthenticationError
try:
response = client.create.completion(
messages=[{"role": "user", "content": "Hello"}],
model="gpt-4.1"
)
except AuthenticationError:
print("Invalid API key")
except APIError as e:
print(f"API error: {e}")
Model Support
Tool-Compatible Models
gpt-4.1gpt-4.1-minigpt-4.1-nanoastar-gpt-4.1
Other models can be used for basic completions but do not support tool calling.
Metadata
Release files for astarcloud 0.1.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| astarcloud-0.1.17.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| astarcloud-0.1.17-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.3 kB
Release files / astarcloud-0.1.17.tar.gz
| Download URL | astarcloud-0.1.17.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
911d512f356062c452d1fee9b1000665cc4a4a704efa7c632710b261af14a874
|
|
BLAKE2b-256 checksum How to use checksums |
1b2a8c03bf3ba2dd26aa2bab9faed175b5ac6689bcb05377edbcec512f42f004
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.8
|
Release files / astarcloud-0.1.17-py3-none-any.whl
| Download URL | astarcloud-0.1.17-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c740b37e332a24a922ba2a927a5846744bb84a2ab236da167c019f7fd1ce26a8
|
|
BLAKE2b-256 checksum How to use checksums |
e8a5b7ac2722ecec549fb235375a6ef24db3cfc940a678a8770b63f20a3c31a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.8
|