fortress-optimizer 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: fortress-optimizer
3
+ Version: 1.0.0
4
+ Summary: AI token optimization SDK — reduce LLM API costs by 10-20%
5
+ Author-email: Fortress Optimizer <support@fortress-optimizer.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://fortress-optimizer.com
8
+ Project-URL: Documentation, https://fortress-optimizer.com/docs
9
+ Project-URL: Repository, https://github.com/diawest82/fortress-optimizer-monorepo
10
+ Keywords: tokens,optimization,llm,openai,anthropic,prompt-engineering,cost-reduction
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.28.0
24
+
25
+ # Fortress Optimizer
26
+
27
+ Reduce your AI API costs by 10-20% with real-time prompt optimization.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install fortress-optimizer
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ from fortress_optimizer import FortressClient
39
+
40
+ client = FortressClient(api_key="fk_your_key_here")
41
+
42
+ # Optimize a prompt
43
+ result = client.optimize("Can you please help me write a detailed analysis of this data")
44
+
45
+ print(result["optimization"]["optimized_prompt"])
46
+ # → "Write a detailed analysis of this data"
47
+
48
+ print(f"Saved {result['tokens']['savings_percentage']}% tokens")
49
+ # → "Saved 40.0% tokens"
50
+ ```
51
+
52
+ ## Features
53
+
54
+ - **10-20% token savings** on casual and business prompts
55
+ - **3 optimization levels**: conservative, balanced, aggressive
56
+ - **All major LLM providers**: OpenAI, Anthropic, Google, and more
57
+ - **Automatic retries** with exponential backoff
58
+ - **Usage tracking** per API key
59
+
60
+ ## API
61
+
62
+ ```python
63
+ # Optimize a prompt
64
+ result = client.optimize(prompt, level="balanced", provider="openai")
65
+
66
+ # Check usage
67
+ usage = client.get_usage()
68
+
69
+ # List providers
70
+ providers = client.get_providers()
71
+
72
+ # Health check
73
+ is_healthy = client.health_check()
74
+ ```
75
+
76
+ ## Get an API Key
77
+
78
+ Sign up free at [fortress-optimizer.com](https://fortress-optimizer.com) — 50,000 tokens/month, no credit card required.
@@ -0,0 +1,54 @@
1
+ # Fortress Optimizer
2
+
3
+ Reduce your AI API costs by 10-20% with real-time prompt optimization.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install fortress-optimizer
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from fortress_optimizer import FortressClient
15
+
16
+ client = FortressClient(api_key="fk_your_key_here")
17
+
18
+ # Optimize a prompt
19
+ result = client.optimize("Can you please help me write a detailed analysis of this data")
20
+
21
+ print(result["optimization"]["optimized_prompt"])
22
+ # → "Write a detailed analysis of this data"
23
+
24
+ print(f"Saved {result['tokens']['savings_percentage']}% tokens")
25
+ # → "Saved 40.0% tokens"
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - **10-20% token savings** on casual and business prompts
31
+ - **3 optimization levels**: conservative, balanced, aggressive
32
+ - **All major LLM providers**: OpenAI, Anthropic, Google, and more
33
+ - **Automatic retries** with exponential backoff
34
+ - **Usage tracking** per API key
35
+
36
+ ## API
37
+
38
+ ```python
39
+ # Optimize a prompt
40
+ result = client.optimize(prompt, level="balanced", provider="openai")
41
+
42
+ # Check usage
43
+ usage = client.get_usage()
44
+
45
+ # List providers
46
+ providers = client.get_providers()
47
+
48
+ # Health check
49
+ is_healthy = client.health_check()
50
+ ```
51
+
52
+ ## Get an API Key
53
+
54
+ Sign up free at [fortress-optimizer.com](https://fortress-optimizer.com) — 50,000 tokens/month, no credit card required.
@@ -0,0 +1,18 @@
1
+ """
2
+ Fortress Token Optimizer — Python SDK
3
+
4
+ Reduce LLM API costs by 10-20% with real-time prompt optimization.
5
+
6
+ Usage:
7
+ from fortress_optimizer import FortressClient
8
+
9
+ client = FortressClient(api_key="fk_your_key_here")
10
+ result = client.optimize("Your prompt here")
11
+ print(result["optimization"]["optimized_prompt"])
12
+ print(f"Saved {result['tokens']['savings_percentage']}% tokens")
13
+ """
14
+
15
+ from .client import FortressClient
16
+
17
+ __version__ = "1.0.0"
18
+ __all__ = ["FortressClient"]
@@ -0,0 +1,112 @@
1
+ """
2
+ Fortress Token Optimizer — Python Client
3
+
4
+ Safe HTTP wrapper around the Fortress API.
5
+ The optimization algorithm runs server-side only.
6
+ """
7
+
8
+ import time
9
+ import requests
10
+ from typing import Optional, Dict, Any, List
11
+
12
+
13
+ class FortressClient:
14
+ """Client for the Fortress Token Optimization API."""
15
+
16
+ def __init__(
17
+ self,
18
+ api_key: str,
19
+ base_url: str = "https://api.fortress-optimizer.com",
20
+ timeout: int = 10,
21
+ max_retries: int = 3,
22
+ ):
23
+ if not api_key:
24
+ raise ValueError("API key is required")
25
+ if not base_url.startswith("https://") and "localhost" not in base_url:
26
+ raise ValueError("Fortress API requires HTTPS")
27
+
28
+ self.base_url = base_url.rstrip("/")
29
+ self.timeout = timeout
30
+ self.max_retries = min(max_retries, 10)
31
+ self.session = requests.Session()
32
+ self.session.headers.update({
33
+ "Authorization": f"Bearer {api_key}",
34
+ "X-API-Key": api_key,
35
+ "X-Client-Version": "1.0.0",
36
+ "Content-Type": "application/json",
37
+ })
38
+
39
+ def optimize(
40
+ self,
41
+ prompt: str,
42
+ level: str = "balanced",
43
+ provider: str = "openai",
44
+ ) -> Dict[str, Any]:
45
+ """
46
+ Optimize a prompt for token efficiency.
47
+
48
+ Args:
49
+ prompt: The prompt to optimize
50
+ level: 'conservative', 'balanced', or 'aggressive'
51
+ provider: LLM provider ('openai', 'anthropic', etc.)
52
+
53
+ Returns:
54
+ Dict with keys: request_id, status, optimization, tokens, timestamp
55
+ """
56
+ return self._request("POST", "/api/optimize", json={
57
+ "prompt": prompt,
58
+ "level": level,
59
+ "provider": provider,
60
+ })
61
+
62
+ def get_usage(self) -> Dict[str, Any]:
63
+ """Get token usage statistics for your API key."""
64
+ return self._request("GET", "/api/usage")
65
+
66
+ def get_providers(self) -> List[str]:
67
+ """Get list of supported LLM providers."""
68
+ data = self._request("GET", "/api/providers")
69
+ return data.get("providers", [])
70
+
71
+ def health_check(self) -> bool:
72
+ """Check if the API is healthy."""
73
+ try:
74
+ data = self._request("GET", "/health")
75
+ return data.get("status") == "healthy"
76
+ except Exception:
77
+ return False
78
+
79
+ def _request(self, method: str, path: str, **kwargs) -> Dict[str, Any]:
80
+ """Make an HTTP request with retry logic."""
81
+ url = f"{self.base_url}{path}"
82
+ last_error = None
83
+
84
+ for attempt in range(self.max_retries + 1):
85
+ try:
86
+ resp = self.session.request(
87
+ method, url, timeout=self.timeout, **kwargs
88
+ )
89
+
90
+ if resp.status_code == 401:
91
+ raise ValueError("Invalid API key")
92
+ if resp.status_code == 400:
93
+ raise ValueError(f"Invalid request: {resp.text}")
94
+
95
+ resp.raise_for_status()
96
+ return resp.json()
97
+
98
+ except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as e:
99
+ last_error = e
100
+ except requests.exceptions.HTTPError as e:
101
+ if resp.status_code == 429 or resp.status_code >= 500:
102
+ last_error = e
103
+ else:
104
+ raise
105
+ except ValueError:
106
+ raise
107
+
108
+ if attempt < self.max_retries:
109
+ delay = min(2 ** attempt, 10)
110
+ time.sleep(delay)
111
+
112
+ raise last_error or Exception("Request failed after retries")
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: fortress-optimizer
3
+ Version: 1.0.0
4
+ Summary: AI token optimization SDK — reduce LLM API costs by 10-20%
5
+ Author-email: Fortress Optimizer <support@fortress-optimizer.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://fortress-optimizer.com
8
+ Project-URL: Documentation, https://fortress-optimizer.com/docs
9
+ Project-URL: Repository, https://github.com/diawest82/fortress-optimizer-monorepo
10
+ Keywords: tokens,optimization,llm,openai,anthropic,prompt-engineering,cost-reduction
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.28.0
24
+
25
+ # Fortress Optimizer
26
+
27
+ Reduce your AI API costs by 10-20% with real-time prompt optimization.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install fortress-optimizer
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ```python
38
+ from fortress_optimizer import FortressClient
39
+
40
+ client = FortressClient(api_key="fk_your_key_here")
41
+
42
+ # Optimize a prompt
43
+ result = client.optimize("Can you please help me write a detailed analysis of this data")
44
+
45
+ print(result["optimization"]["optimized_prompt"])
46
+ # → "Write a detailed analysis of this data"
47
+
48
+ print(f"Saved {result['tokens']['savings_percentage']}% tokens")
49
+ # → "Saved 40.0% tokens"
50
+ ```
51
+
52
+ ## Features
53
+
54
+ - **10-20% token savings** on casual and business prompts
55
+ - **3 optimization levels**: conservative, balanced, aggressive
56
+ - **All major LLM providers**: OpenAI, Anthropic, Google, and more
57
+ - **Automatic retries** with exponential backoff
58
+ - **Usage tracking** per API key
59
+
60
+ ## API
61
+
62
+ ```python
63
+ # Optimize a prompt
64
+ result = client.optimize(prompt, level="balanced", provider="openai")
65
+
66
+ # Check usage
67
+ usage = client.get_usage()
68
+
69
+ # List providers
70
+ providers = client.get_providers()
71
+
72
+ # Health check
73
+ is_healthy = client.health_check()
74
+ ```
75
+
76
+ ## Get an API Key
77
+
78
+ Sign up free at [fortress-optimizer.com](https://fortress-optimizer.com) — 50,000 tokens/month, no credit card required.
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ fortress_optimizer/__init__.py
4
+ fortress_optimizer/client.py
5
+ fortress_optimizer.egg-info/PKG-INFO
6
+ fortress_optimizer.egg-info/SOURCES.txt
7
+ fortress_optimizer.egg-info/dependency_links.txt
8
+ fortress_optimizer.egg-info/requires.txt
9
+ fortress_optimizer.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1 @@
1
+ fortress_optimizer
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fortress-optimizer"
7
+ version = "1.0.0"
8
+ description = "AI token optimization SDK — reduce LLM API costs by 10-20%"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ {name = "Fortress Optimizer", email = "support@fortress-optimizer.com"},
14
+ ]
15
+ keywords = ["tokens", "optimization", "llm", "openai", "anthropic", "prompt-engineering", "cost-reduction"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Topic :: Software Development :: Libraries",
27
+ ]
28
+ dependencies = [
29
+ "requests>=2.28.0",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://fortress-optimizer.com"
34
+ Documentation = "https://fortress-optimizer.com/docs"
35
+ Repository = "https://github.com/diawest82/fortress-optimizer-monorepo"
36
+
37
+ [tool.setuptools.packages.find]
38
+ include = ["fortress_optimizer*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+