Skip to main content

SciTeX GenAI (scitex-genai)

SciTeX

Modality-organised generative-AI provider abstraction for scientific research.

Full Documentation · uv pip install scitex-genai[all]

pypi python docs

tests install-check quality cov


Problem and Solution

# Problem Solution
1 Per-provider boilerplate — every project re-writes thin wrappers around openai, anthropic, google.genai, groq, etc., each with subtly different cost / streaming / history semantics. Unified GenAI factory — same call shape across OpenAI, Anthropic, Google, Groq, DeepSeek, Perplexity, Llama. Cost tracking, conversation history, and message formatting are provider-agnostic.
2 Modality fragmentation — generative AI is splintering by modality (text, agents, image, audio, video, embeddings, multimodal); ad-hoc namespaces age badly. Modality-organised layout — scitex_genai.{llm,agent,image,audio,video,embed,multimodal} is the public top-level shape from day one. Reserved namespaces import successfully but raise NotImplementedError until features land, so import paths never need to migrate.
3 Heavy LLM SDKs leak into ML workflows — pulling in scikit-learn shouldn't pull openai and friends, and vice versa. Split package — classical / deep ML lives in scitex-ml; scitex-genai carries only generative-AI deps.
4 Future-proofing for litellm + Ollama — locking the public API to one provider SDK closes off cheap routing improvements. Litellm-ready façade — the planned llm rewrite routes through litellm, giving 100+ providers with one OpenAI-compatible interface (Ollama is just model="ollama/llama3") without changing the GenAI(...) call surface.

Installation

pip install scitex-genai            # core (LLM providers)
pip install scitex-genai[agent]     # + claude-agent-sdk (forthcoming `agent` submodule)
pip install scitex-genai[litellm]   # + litellm router (preview)
pip install scitex-genai[gateway]   # + Anthropic-compatible model gateway
pip install scitex-genai[ollama]    # + local ollama
pip install scitex-genai[all]       # everything available today

Through the umbrella: pip install scitex[genai]. Requires Python ≥ 3.10.

Claude Code with a Codex subscription backend

The gateway keeps Claude Code as the agent harness. It translates only the model protocol and never executes tools returned by Codex.

export SCITEX_GENAI_GATEWAY_API_KEY="$(openssl rand -hex 32)"
scitex-genai-gateway --host 127.0.0.1 --port 8765

By default the gateway discovers ~/.scitex/agent-container/accounts/openai/*/auth.json. Set the path-separated SCITEX_GENAI_CODEX_HOMES only to override that store. Each configured directory contains an auth.json created by codex login. Tokens remain in those files and are refreshed atomically. Account selection is sticky per session, ranks accounts by Codex usage-window headroom, spreads concurrent sessions, and rotates away from rate-limited accounts. The rotation selector is invoked even for a one-account pool.

Point Claude Code at the service without changing its hooks, skills, tools, or project instructions:

export ANTHROPIC_BASE_URL="http://127.0.0.1:8765"
export ANTHROPIC_API_KEY="$SCITEX_GENAI_GATEWAY_API_KEY"
export ANTHROPIC_MODEL="gpt-5.4"
claude

This integration uses the Codex client subscription transport rather than the separately billed OpenAI API. See the gateway skill for its protocol coverage and operational limitations.

Quick Start

import scitex_genai

ai = scitex_genai.GenAI(model="gpt-4o-mini")
print(ai("Explain neural networks in one sentence."))
print("cost USD:", ai.cost)

# Switch backends without changing the call shape:
ai = scitex_genai.GenAI(model="claude-sonnet-4-6")
ai("Same call, different provider.")

For a runnable walk-through see examples/01_genai.ipynb.

Demo

A runnable provider walk-through (init GenAI, single completion, cost summary, provider switch) lives in examples/01_genai.ipynb. Each cell skips gracefully when the relevant API key is unset.

flowchart LR
    User[your code] -->|GenAI(model)| Factory[scitex_genai.llm.GenAI]
    Factory -->|dispatch| OpenAI[OpenAI]
    Factory --> Anthropic[Anthropic]
    Factory --> Google[Google]
    Factory --> Groq[Groq]
    Factory --> DeepSeek[DeepSeek]
    Factory --> Perplexity[Perplexity]
    Factory --> Llama[Llama]
    OpenAI -.->|tokens / cost| Tracker[BaseGenAI<br/>cost + history]
    Anthropic -.-> Tracker
    Google -.-> Tracker
    Groq -.-> Tracker
    Tracker --> Out[ai&#40;...&#41; · ai.cost · ai.history]

A second examples/example_genai.py runs the same flow as a script and is wired into tests/examples/test_example_genai.py for CI smoke coverage.

Architecture

scitex-genai is organised top-down by modality, not by provider:

scitex-python (umbrella)
    └── scitex.genai ── thin sys.modules-aliasing shim
                        └── scitex_genai (this package)
                              ├── llm/         provider factory ``GenAI``
                              │                 ├── _BaseGenAI         common interface
                              │                 ├── _OpenAI / _Anthropic / _Google /
                              │                 │   _Groq / _DeepSeek / _Perplexity / _Llama
                              │                 ├── _PARAMS            model catalogue
                              │                 ├── _calc_cost         token-cost accounting
                              │                 └── _format_output_func text/markdown formatting
                              ├── gateway/     structured Anthropic ↔ Codex protocol bridge
                              ├── agent/        reserved (claude-agent-sdk wrapper planned)
                              ├── image/        reserved
                              ├── audio/        reserved
                              ├── video/        reserved
                              ├── embed/        reserved
                              └── multimodal/   reserved

Reserved modality namespaces import successfully but raise NotImplementedError on attribute access, so the public import paths are stable as features land. Provider SDKs (openai, anthropic, google-genai, groq) are eager core dependencies today; a follow-up will route llm/ through litellm to demote them to optional and add Ollama out of the box.

Modality layout

Submodule Status Notes
scitex_genai.llm ✅ implemented Provider factory GenAI. Litellm-backed in a follow-up.
scitex_genai.agent 🔒 reserved Wrapper over claude-agent-sdk and friends planned.
scitex_genai.image 🔒 reserved Image generation / editing.
scitex_genai.audio 🔒 reserved TTS / STT / music.
scitex_genai.video 🔒 reserved Video generation.
scitex_genai.embed 🔒 reserved Embeddings.
scitex_genai.multimodal 🔒 reserved Any-to-any unified models.

Reserved namespaces import successfully but raise NotImplementedError on attribute access — import paths are stable as features land.

4 Interfaces

Python API ⭐⭐⭐ (primary)
from scitex_genai import GenAI

ai = GenAI(model="gpt-4o-mini")
print(ai("..."))
print("cost USD:", ai.cost)

Full API reference

CLI ⭐ — gateway

scitex-genai-gateway serves an authenticated Anthropic-compatible endpoint backed by one or more Codex subscription accounts.

MCP ⭐ — none

No MCP server in this package today. The umbrella surfaces LLM-related MCP tools separately.

Skills ⭐⭐

Skill index for AI agents lives at src/scitex_genai/_skills/scitex-genai/SKILL.md. Sub-skill llm.md documents the provider factory.

Full skills directory

Part of SciTeX

scitex-genai is part of SciTeX. Install via the umbrella with pip install scitex[genai] to use as scitex.genai (Python).

import scitex

scitex.genai.GenAI  # same object as scitex_genai.GenAI
scitex.genai.llm    # same object as scitex_genai.llm

scitex.genai delegates to scitex_genai — they share the same API.

The SciTeX system follows the Four Freedoms for Research below, inspired by the Free Software Definition:

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.


SciTeX

Metadata

Release files for scitex-genai 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scitex-genai 0.2.1
File Size Uploaded Provenance
scitex_genai-0.2.1.tar.gz 8.7 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for scitex-genai 0.2.1
File Interpreter ABI Platform
scitex_genai-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 MB

Release files / scitex_genai-0.2.1.tar.gz

Download URL scitex_genai-0.2.1.tar.gz
Size 8.7 MB
Tags Source
SHA-256 checksum
How to use checksums
96ec2def7d6975255d099ede8b33e091d5fc9562f39209a1c3c3b5a25743a64c
BLAKE2b-256 checksum
How to use checksums
1c0988a8e60a1f28496b0b6e3990028ef4cd21871e1fd192f4fccc95aa89e747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / scitex_genai-0.2.1-py3-none-any.whl

Download URL scitex_genai-0.2.1-py3-none-any.whl
Size 8.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
de1aa158b5fea07e41b3fd5038a744c874fc11603f97e5eaa07b2fbbcb3abf7b
BLAKE2b-256 checksum
How to use checksums
c9985815b0a367c31ee84b80612121933490d0a581218fab3766514d6564accd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Security for scitex-genai 0.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page