oiaapi (OpenAI API Python Interface)
A minimalist yet powerful Python interface for the OpenAI API, designed for structured conversation management and advanced multimodal interactions.
Features
- Centralized Client: Use a single
Clientto manage your connection and spawn multiple chat sessions. - Variadic Chat Interface: Send multiple message components directly:
chat.chat("Text", Image("local.png"), "More text"). - Node-Based History: Every interaction is a node with an incremental ID.
- Context Control: Activate or deactivate conversation nodes by their ID to manage the model's window.
- Enhanced Metrics: Track token usage, models, and active nodes per request with built-in Pandas integration.
- Multimodal Support: Handle local images (auto-base64 encoding) and remote URLs seamlessly.
- State Persistence: Save
Chatstates and load them via theClientto resume sessions. - Deep Copy: Create independent clones of your chat session.
Installation
# Via Pip (once published)
pip install oiaapi
# From source
git clone https://github.com/artitzco/openai-api.git
cd openai-api
pip install .
Quick Start
from oiaapi import Client, Image
# Initialize the main client
client = Client(api_key="your-api-key") # or use OPENAI_API_KEY env var
# Start a new chat session
chat = client.chat(model="gpt-4o-mini", system_prompt="You are a helpful assistant.")
# Basic Chat
response = chat.chat("Hello! What can you do?")
print(response)
# Multimodal Chat (Local and URL)
chat.chat(
"Analyze these images:",
Image("path/to/local_image.png"),
"and also this one:",
Image("https://example.com/image.jpg")
)
# Manage History
df_history = chat.history.to_dataframe()
chat.history.toggle(node_id=1, active=False) # Context management
# Persistence
chat.save("my_session.json")
new_chat_recovered = client.load_chat("my_session.json")
Project Structure
src/oiaapi/: Core library modules.__init__.py: Contains theClientfactory and exports.core.py: Contains theChatsession manager.history.py: Logic for node-based conversation management.metrics.py: Token usage and request tracking.content.py: Multimodal data builders (Images, etc.).
notebooks/: Interactive guides and testing playgrounds.img/: Storage for sample assets.output/: Default location for saved session JSONs.
License
MIT
Metadata
Release files for oiaapi 0.1.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 | Actions |
|---|---|---|---|---|
| oiaapi-0.1.0.tar.gz | 11.2 kB | Without provenance | Details for oiaapi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oiaapi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for oiaapi-0.1.0-py3-none-any.whl |
Total release size: 23.0 kB
Release files / oiaapi-0.1.0.tar.gz
| Download URL | oiaapi-0.1.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c51613f076cf4b33802ec0f659a3f3bde409c3ffefb26100542927a97c8818ce
|
|
BLAKE2b-256 checksum How to use checksums |
2cc6965effd3dfc3927030ce424bb1c73f4d680678e3c54759e077cdadb51159
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / oiaapi-0.1.0-py3-none-any.whl
| Download URL | oiaapi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cdb7f30f55f1a53d798708c04a9d038fcad5d4f2ac3b70608315dc6c92cc7ad
|
|
BLAKE2b-256 checksum How to use checksums |
b36f25ffc1eace8c1498a6ffccb048400ce3d0cbfa2a88fe95dbc64a83384454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Security for oiaapi 0.1.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.