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 layoutscitex_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_CODEX_HOMES="$HOME/.codex-alpha:$HOME/.codex-beta"
export SCITEX_GENAI_GATEWAY_API_KEY="$(openssl rand -hex 32)"
scitex-genai-gateway --host 127.0.0.1 --port 8765

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.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scitex_genai-0.1.3.tar.gz (8.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scitex_genai-0.1.3-py3-none-any.whl (8.3 MB view details)

Uploaded Python 3

File details

Details for the file scitex_genai-0.1.3.tar.gz.

File metadata

  • Download URL: scitex_genai-0.1.3.tar.gz
  • Upload date:
  • Size: 8.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for scitex_genai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cebf76e5cd84f4b0086c0567608c159ec388013a15a25c4408c452839693e1cd
MD5 30002b7c9a7b8500c63f4fd1f92ea291
BLAKE2b-256 155b47468a1be09a866f5d02a10cce57b22212a653e8d1958b74087a3ff50cd3

See more details on using hashes here.

File details

Details for the file scitex_genai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: scitex_genai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for scitex_genai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a6619535d0d08aa12a72ccdcb658ae2732d1ccb46aa9ea196da332a5ca6936e1
MD5 06f1c82bc63b668544364f1533950b2f
BLAKE2b-256 30acbed1b2969760d16ac1eafcdeb96fb8f9a4c9c5faf846a09e72e34e4a470d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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