Repository navigation
Expand file tree
/
Copy pathopenapi.json
More file actions
234 lines (234 loc) · 6.75 KB
/
Copy pathopenapi.json
File metadata and controls
234 lines (234 loc) · 6.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
{
"openapi": "3.0.3",
"info": {
"title": "Semantic Cache & Token Saver API",
"description": "Ultra-Fast Algorithmic Semantic Vector Cache for LLMs (OpenAI GPT-4o, Claude 3.5, Gemini 1.5, Ollama). Eliminates redundant LLM API calls, cuts OpenAI token bills by 30-60%, and accelerates responses from 1500ms down to 10ms.",
"version": "1.0.0",
"contact": {
"name": "TopAI SaaS Dev",
"email": "top.ai.saas@gmail.com"
}
},
"servers": [
{
"url": "https://semantic-cache.topaisaas.workers.dev",
"description": "Cloudflare Workers Edge Production"
}
],
"paths": {
"/v1/cache/check": {
"post": {
"summary": "Check Semantic Cache for a Query",
"description": "Performs instant vector similarity check against cached queries in < 2ms.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"query"
],
"properties": {
"query": {
"type": "string",
"example": "How do I reset my account password?"
},
"namespace": {
"type": "string",
"example": "customer-support",
"default": "default"
},
"similarity_threshold": {
"type": "number",
"example": 0.85,
"default": 0.85
}
}
}
}
}
},
"responses": {
"200": {
"description": "Cache check result returned",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
},
"hit": {
"type": "boolean",
"example": true
},
"similarity": {
"type": "number",
"example": 0.94
},
"cached_response": {
"type": "string"
},
"tokens_saved": {
"type": "integer",
"example": 320
},
"estimated_cost_saved_usd": {
"type": "number",
"example": 0.0032
},
"estimated_latency_saved_ms": {
"type": "integer",
"example": 1200
}
}
}
}
}
},
"400": {
"description": "Invalid parameters"
}
}
}
},
"/v1/cache/set": {
"post": {
"summary": "Store Query and Response in Cache",
"description": "Saves a query-response pair and computes its feature vector for future hits.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"query",
"response"
],
"properties": {
"query": {
"type": "string",
"example": "How do I reset my account password?"
},
"response": {
"type": "string",
"example": "Navigate to Settings > Security > Click 'Reset Password' and follow email instructions."
},
"namespace": {
"type": "string",
"example": "customer-support",
"default": "default"
},
"ttl_seconds": {
"type": "integer",
"example": 86400,
"default": 86400
}
}
}
}
}
},
"responses": {
"200": {
"description": "Pair stored successfully"
}
}
}
},
"/v1/cache/batch-check": {
"post": {
"summary": "Batch Semantic Cache Lookup",
"description": "Check up to 20 queries simultaneously for parallel agent pipelines.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"queries"
],
"properties": {
"queries": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"Password reset guide",
"Pricing plans for enterprise"
]
},
"namespace": {
"type": "string",
"default": "default"
},
"similarity_threshold": {
"type": "number",
"default": 0.85
}
}
}
}
}
},
"responses": {
"200": {
"description": "Batch check completed"
}
}
}
},
"/v1/cache/stats": {
"get": {
"summary": "Get Cache & Cost Savings Statistics",
"description": "Returns hit ratio, total tokens saved, and estimated USD cost savings.",
"responses": {
"200": {
"description": "Global stats returned"
}
}
}
},
"/v1/cache/clear": {
"post": {
"summary": "Clear Namespace or All Cache",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"namespace": {
"type": "string",
"example": "customer-support"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Cache cleared"
}
}
}
},
"/v1/health": {
"get": {
"summary": "API Healthcheck",
"responses": {
"200": {
"description": "Service is operational"
}
}
}
}
}
}