Lightweight Python AI client/router with clean provider architecture, retries, and structured output.
Project description
JavaxFlash v3.0.0
JavaxFlash is a lightweight Python AI client and router for multi-provider prompt workflows. It keeps the public API small while providing stronger foundations for production use: configurable retries, cleaner routing, structured output parsing, and optional Tavily-backed web grounding.
Overview
JavaxFlash is designed for developers who want:
- one simple client for multiple AI providers
- lightweight provider routing with sensible defaults
- configurable retry and fallback behavior
- optional grounded answers using Tavily skills
- structured JSON-style output without a heavy framework
The library is intentionally synchronous and compact in v3.0.0. It does not include streaming, chat memory, or async support in this release.
Installation
Install the package locally:
pip install javaxflash
Quick Start
from javaxFlash import Client
client = Client()
response = client.flash("Explain the difference between REST and GraphQL in simple terms.")
print(response.text)
print(response.provider)
print(response.model_used)
print(response.route_reason)
ask() is available as a convenience alias:
response = client.ask("What is Python?")
Core Features
- Canonical provider architecture with
flashanddeepseek - Safer
POST-based transport with timeout handling - Configurable retry logic with backoff and jitter
- Optional provider fallback
- Structured output parsing with lightweight schemas
- Tavily-powered skills for
search,extract, andcrawl - Automatic or manual skill usage for grounded answers
- Clean response objects with routing, retry, latency, and skill metadata
Usage
Basic Usage
from javaxFlash import Client
client = Client()
response = client.flash("Summarize the purpose of retry logic in API clients.")
print(response.text)
Provider Selection
Let the router decide:
response = client.flash("What is Python used for?")
print(response.provider)
Force a provider:
response = client.flash("Use the flash provider.", provider="flash")
response = client.flash("Analyze this architecture tradeoff.", provider="deepseek")
Use routing modes:
fast = client.flash("Summarize HTTP status codes.", mode="fast")
reasoning = client.flash("Compare monolith vs microservices for a growing SaaS.", mode="reasoning")
Backward compatibility note: provider="gemini" is still accepted and resolves to flash.
Retry Configuration
from javaxFlash import Client, Config, RetryExhaustedError, TimeoutError
config = Config(
timeout=20.0,
max_retries=3,
backoff_base=0.5,
backoff_multiplier=2.0,
backoff_max=8.0,
jitter=0.2,
fallback_enabled=True,
)
client = Client(config)
try:
response = client.flash("Summarize retry strategies for HTTP clients.")
print(response.text)
print(response.retry_count)
except (TimeoutError, RetryExhaustedError) as exc:
print(exc)
Tool Usage
The tool system is designed to support the AI response, not replace it. Tool data is cleaned internally and injected into the model prompt as grounding context. Users receive a normal AI answer, not raw tool output objects.
Automatic Skill Usage
from javaxFlash import Client, Config
client = Client(
Config(
tavily_api_key="your-tavily-api-key",
auto_search=True,
)
)
response = client.flash("What is the latest Python release?")
print(response.text)
print(response.search_used)
print(response.search_query)
Manual Skill Usage
Force specific skills when you want grounded answers:
response = client.flash(
"What changed in the latest Python release?",
skills="search",
)
response = client.flash(
"Summarize this page: https://docs.python.org/3/whatsnew/",
skills=["extract"],
)
response = client.flash(
"Crawl docs from https://docs.example.com/retries and summarize the guidance.",
skills=["crawl"],
crawl_instructions="Focus on retry recommendations and edge cases.",
)
Supported skills in v3.0.0:
searchextractcrawl
Important behavior:
- Skill output is cleaned before it is used
- Raw
ToolResult(...)objects are not returned fromflash(...) - Manual and automatic skill usage both produce a final AI answer
Structured Output
Use a lightweight schema when you want predictable JSON-shaped output.
from javaxFlash import Client, JsonSchema
task_schema = JsonSchema(
name="task_summary",
fields={
"title": str,
"priority": str,
"action_items": [str],
},
)
client = Client()
response = client.flash(
"Turn this into a compact task plan for backend cleanup.",
schema=task_schema,
)
print(response.structured_output)
You can also use a dataclass:
from dataclasses import dataclass
from javaxFlash import Client
@dataclass
class TicketSummary:
title: str
priority: str
client = Client()
response = client.flash("Summarize this bug report.", schema=TicketSummary)
print(response.structured_output.title)
Configuration Guide
Common configuration fields:
timeoutmax_retriesbackoff_basebackoff_multiplierbackoff_maxjitterretry_status_codesdefault_providerdefault_modelprovider_modelsfallback_enabledfallback_providerauto_routedebugcapture_raw_responseauto_searchtavily_api_keysearch_tool_namesearch_max_resultssearch_timeout
Example:
from javaxFlash import Client, Config
config = Config(
timeout=15.0,
max_retries=2,
default_provider="flash",
fallback_enabled=True,
fallback_provider="deepseek",
auto_search=False,
tavily_api_key="your-tavily-api-key",
)
client = Client(config)
Environment Variables
Environment-based configuration is optional:
from javaxFlash import Config
config = Config.from_env()
Supported environment variables include:
JAVAXFLASH_TIMEOUTJAVAXFLASH_MAX_RETRIESJAVAXFLASH_BACKOFF_BASEJAVAXFLASH_BACKOFF_MULTIPLIERJAVAXFLASH_BACKOFF_MAXJAVAXFLASH_JITTERJAVAXFLASH_DEFAULT_PROVIDERJAVAXFLASH_DEFAULT_MODELJAVAXFLASH_FALLBACK_PROVIDERJAVAXFLASH_PROVIDER_MODELSJAVAXFLASH_AUTO_ROUTEJAVAXFLASH_AUTO_SEARCHJAVAXFLASH_TAVILY_API_KEYJAVAXFLASH_SEARCH_TOOL_NAMEJAVAXFLASH_SEARCH_MAX_RESULTSJAVAXFLASH_SEARCH_TIMEOUTJAVAXFLASH_DEBUG
Response Model
Each request returns FlashResponse:
response.text
response.provider
response.model_used
response.route_reason
response.retry_count
response.latency_ms
response.raw
response.structured_output
response.search_used
response.search_query
response.search_summary
response.skills_used
response.skills_summary
raw is only included when capture_raw_response=True or include_raw=True.
Error Handling
Library-specific exceptions:
ProviderErrorTimeoutErrorRetryExhaustedErrorSchemaValidationErrorToolExecutionError
Typical example:
from javaxFlash import Client, ToolExecutionError
client = Client()
try:
response = client.flash("What is the latest Python release?", skills="search")
print(response.text)
except ToolExecutionError as exc:
print(exc)
Best Practices
- Use
auto_search=Trueonly when you want lightweight web grounding for freshness-sensitive prompts. - Use manual
skills=when you know the answer should be grounded by search, extraction, or crawling. - Keep schemas small and explicit for the best structured-output reliability.
- Enable
capture_raw_responseonly for debugging or diagnostics. - Prefer provider forcing only when you have a clear reason; otherwise let routing do the work.
Limitations
- Synchronous only in
v3.0.0 - No streaming support
- No async API
- No chat history or memory layer
- Tooling is currently Tavily-focused and limited to
search,extract, andcrawl - Output quality still depends on upstream model and search provider behavior
Examples
Working examples are provided in:
examples/basic_usage.pyexamples/provider_selection.pyexamples/retry_config.pyexamples/structured_output.pyexamples/tavily_search.py
Testing
Run the test suite:
./.venv/bin/pytest -q
Version
This release is aligned with v3.0.0.
Project details
Release history Release notifications | RSS feed
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 javaxflash-3.0.0.tar.gz.
File metadata
- Download URL: javaxflash-3.0.0.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2dc0d8e10c53cbb6d393194592be40976232f6490f09a000a3c09e2676dd3ff
|
|
| MD5 |
f21b0f7ab5a7ceba4d21e3473f03f4de
|
|
| BLAKE2b-256 |
40d25ad7c4112af9234dbaf29a1b9b29f5547540c4be9beea54cbbbfc2d03578
|
File details
Details for the file javaxflash-3.0.0-py3-none-any.whl.
File metadata
- Download URL: javaxflash-3.0.0-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6088ec4159e4caf9f58d1edbd2fc5984274fbd18bfa2a7f8f23506011e302fc4
|
|
| MD5 |
4ea9b9ee415be1e40ee59e8f2825ecdc
|
|
| BLAKE2b-256 |
9412e6df4910aa092812442b372def2e508b2fdffb4118da6c4c6c414ecaae84
|