Rox-Turbo commited on
Commit
58ec31b
·
verified ·
1 Parent(s): 8816398

Upload 12 files

Browse files
README.md CHANGED
@@ -1,110 +1,126 @@
1
- ---
2
- title: nvidia-chat-proxy
3
- emoji: 💬
4
- colorFrom: blue
5
- colorTo: green
6
- sdk: docker
7
- sdk_version: "1.0"
8
- app_port: 8000
9
- pinned: false
10
- ---
11
 
12
- ## NVIDIA Chat Proxy API
13
 
14
- This is a small FastAPI server that proxies requests from your static website to the NVIDIA/`OpenAI` compatible endpoint, so your API key stays on the server and is never exposed in the browser.
15
 
16
- ### 1. Setup
17
 
18
- Create and activate a virtual environment (optional but recommended), then install dependencies:
19
-
20
- ```bash
21
- pip install -r requirements.txt
22
- ```
 
 
 
 
 
23
 
24
- Create a `.env` file in this folder:
25
 
26
  ```bash
27
- echo NVIDIA_API_KEY=your_real_nvidia_key_here > .env
 
 
28
  ```
29
 
30
- > **Important**: Never commit your real key to git or paste it in client-side code.
31
-
32
- ### 2. Run the server
33
 
34
- ```bash
35
- python server.py
36
- ```
37
-
38
- The API will be available at `http://localhost:8000`.
39
-
40
- ### 3. HTTP API
41
-
42
- **Endpoint**: `POST /chat`
43
-
44
- **Request body**:
45
 
46
  ```json
47
  {
48
  "messages": [
49
- { "role": "user", "content": "Hello!" }
50
  ],
51
  "temperature": 1.0,
52
- "top_p": 1.0,
53
  "max_tokens": 512
54
  }
55
  ```
56
 
57
- **Response body**:
58
 
59
  ```json
60
  {
61
- "content": "Model reply here..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
  ```
64
 
65
- ### 4. Example usage from a static website
66
-
67
- ```html
68
- <!DOCTYPE html>
69
- <html>
70
- <head>
71
- <meta charset="UTF-8" />
72
- <title>Chat with NVIDIA Model</title>
73
- </head>
74
- <body>
75
- <textarea id="input" placeholder="Ask something..."></textarea>
76
- <button id="send">Send</button>
77
- <pre id="output"></pre>
78
-
79
- <script>
80
- const API_URL = "http://localhost:8000/chat"; // or your deployed URL
81
-
82
- document.getElementById("send").addEventListener("click", async () => {
83
- const userText = document.getElementById("input").value;
84
-
85
- const body = {
86
- messages: [{ role: "user", content: userText }],
87
- temperature: 1,
88
- top_p: 1,
89
- max_tokens: 512,
90
- };
91
-
92
- const res = await fetch(API_URL, {
93
- method: "POST",
94
- headers: { "Content-Type": "application/json" },
95
- body: JSON.stringify(body),
96
- });
97
-
98
- if (!res.ok) {
99
- document.getElementById("output").textContent =
100
- "Error: " + (await res.text());
101
- return;
102
- }
103
-
104
- const data = await res.json();
105
- document.getElementById("output").textContent = data.content;
106
- });
107
- </script>
108
- </body>
109
- </html>
110
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Rox AI
 
 
 
 
 
 
 
 
 
2
 
3
+ Eight specialized AI models by Mohammad Faiz.
4
 
5
+ **API**: `https://Rox-Turbo-API.hf.space`
6
 
7
+ ## Models
8
 
9
+ | Model | Endpoint | Use Case |
10
+ |-------|----------|----------|
11
+ | Rox Core | `/chat` | General conversation |
12
+ | Rox 2.1 Turbo | `/turbo` | Fast responses |
13
+ | Rox 3.5 Coder | `/coder` | Code generation |
14
+ | Rox 4.5 Turbo | `/turbo45` | Advanced reasoning |
15
+ | Rox 5 Ultra | `/ultra` | Complex tasks |
16
+ | Rox 6 Dyno | `/dyno` | Long context |
17
+ | Rox 7 Coder | `/coder7` | Advanced coding |
18
+ | Rox Vision Max | `/vision` | Visual understanding |
19
 
20
+ ## Quick Start
21
 
22
  ```bash
23
+ curl -X POST https://Rox-Turbo-API.hf.space/chat \
24
+ -H "Content-Type: application/json" \
25
+ -d '{"messages":[{"role":"user","content":"Hello"}]}'
26
  ```
27
 
28
+ ## Usage
 
 
29
 
30
+ ### Request
 
 
 
 
 
 
 
 
 
 
31
 
32
  ```json
33
  {
34
  "messages": [
35
+ {"role": "user", "content": "Your message"}
36
  ],
37
  "temperature": 1.0,
 
38
  "max_tokens": 512
39
  }
40
  ```
41
 
42
+ ### Response
43
 
44
  ```json
45
  {
46
+ "content": "AI response"
47
+ }
48
+ ```
49
+
50
+ ### JavaScript
51
+
52
+ ```javascript
53
+ async function askRox(message, model = 'chat') {
54
+ const response = await fetch(`https://Rox-Turbo-API.hf.space/${model}`, {
55
+ method: 'POST',
56
+ headers: { 'Content-Type': 'application/json' },
57
+ body: JSON.stringify({
58
+ messages: [{ role: 'user', content: message }]
59
+ })
60
+ });
61
+ return (await response.json()).content;
62
  }
63
  ```
64
 
65
+ ### Python
66
+
67
+ ```python
68
+ import requests
69
+
70
+ def ask_rox(message, model='chat'):
71
+ response = requests.post(
72
+ f'https://Rox-Turbo-API.hf.space/{model}',
73
+ json={'messages': [{'role': 'user', 'content': message}]}
74
+ )
75
+ return response.json()['content']
76
+ ```
77
+
78
+ ## Examples
79
+
80
+ ```bash
81
+ # General conversation
82
+ curl -X POST https://Rox-Turbo-API.hf.space/chat \
83
+ -H "Content-Type: application/json" \
84
+ -d '{"messages":[{"role":"user","content":"Explain AI"}]}'
85
+
86
+ # Fast response
87
+ curl -X POST https://Rox-Turbo-API.hf.space/turbo \
88
+ -H "Content-Type: application/json" \
89
+ -d '{"messages":[{"role":"user","content":"What is 2+2?"}]}'
90
+
91
+ # Code generation
92
+ curl -X POST https://Rox-Turbo-API.hf.space/coder \
93
+ -H "Content-Type: application/json" \
94
+ -d '{"messages":[{"role":"user","content":"Write a Python function"}]}'
95
+
96
+ # Advanced reasoning
97
+ curl -X POST https://Rox-Turbo-API.hf.space/turbo45 \
98
+ -H "Content-Type: application/json" \
99
+ -d '{"messages":[{"role":"user","content":"Explain quantum computing"}]}'
 
 
 
 
 
 
 
 
 
 
100
  ```
101
+
102
+ ## Documentation
103
+
104
+ - [Code Examples](docs/CODE.md) - Copy-paste code
105
+ - [Developer Guide](docs/DEVELOPER_GUIDE.md) - Integration guide
106
+ - [Models Guide](docs/MODELS.md) - Model details
107
+ - [API Reference](docs/API_REFERENCE.md) - API docs
108
+
109
+ ## Model Selection
110
+
111
+ - **Rox Core** - General use
112
+ - **Rox 2.1 Turbo** - Speed priority
113
+ - **Rox 3.5 Coder** - Code tasks
114
+ - **Rox 4.5 Turbo** - Complex reasoning
115
+ - **Rox 5 Ultra** - Highest quality
116
+ - **Rox 6 Dyno** - Long documents
117
+ - **Rox 7 Coder** - Advanced code
118
+ - **Rox Vision Max** - Images
119
+
120
+ ## License
121
+
122
+ MIT License
123
+
124
+ ---
125
+
126
+ Built by Mohammad Faiz
__pycache__/server.cpython-312.pyc ADDED
Binary file (16 kB). View file
 
docker-compose.yml CHANGED
@@ -1,9 +1,9 @@
1
  version: "3.9"
2
 
3
  services:
4
- nvidia-chat-proxy:
5
  build: .
6
- container_name: nvidia-chat-proxy
7
  ports:
8
  - "8000:8000"
9
  env_file:
 
1
  version: "3.9"
2
 
3
  services:
4
+ rox-ai:
5
  build: .
6
+ container_name: rox-ai
7
  ports:
8
  - "8000:8000"
9
  env_file:
dockerignore ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.pyo
4
+ *.pyd
5
+ .Python
6
+ env/
7
+ venv/
8
+ .venv/
9
+ build/
10
+ dist/
11
+ *.egg-info/
12
+ .git
13
+ .gitignore
14
+ .env
15
+
docs/API_REFERENCE.md ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # API Reference
2
+
3
+ Technical reference for Rox AI API endpoints.
4
+
5
+ ## Base URL
6
+
7
+ ```
8
+ https://Rox-Turbo-API.hf.space
9
+ ```
10
+
11
+ ---
12
+
13
+ ## Endpoints
14
+
15
+ ### POST /chat - Rox Core
16
+ ### POST /turbo - Rox 2.1 Turbo
17
+ ### POST /coder - Rox 3.5 Coder
18
+ ### POST /turbo45 - Rox 4.5 Turbo
19
+ ### POST /ultra - Rox 5 Ultra
20
+ ### POST /dyno - Rox 6 Dyno
21
+ ### POST /coder7 - Rox 7 Coder
22
+ ### POST /vision - Rox Vision Max
23
+ ### POST /hf/generate - HuggingFace Compatible
24
+
25
+ All endpoints use the same request/response format.
26
+
27
+ #### Request
28
+
29
+ **URL**: `/chat`
30
+ **Method**: `POST`
31
+ **Content-Type**: `application/json`
32
+
33
+ **Body Parameters**:
34
+
35
+ | Parameter | Type | Required | Default | Description |
36
+ |-----------|------|----------|---------|-------------|
37
+ | `messages` | Array<Message> | Yes | - | Array of conversation messages |
38
+ | `temperature` | Float | No | 1.0 | Controls randomness (0.0 - 2.0) |
39
+ | `top_p` | Float | No | 1.0 | Nucleus sampling parameter (0.0 - 1.0) |
40
+ | `max_tokens` | Integer | No | 4096 | Maximum tokens in response |
41
+
42
+ **Message Object**:
43
+
44
+ ```typescript
45
+ {
46
+ role: "user" | "assistant",
47
+ content: string
48
+ }
49
+ ```
50
+
51
+ **Example Request**:
52
+
53
+ ```json
54
+ {
55
+ "messages": [
56
+ {
57
+ "role": "user",
58
+ "content": "What is artificial intelligence?"
59
+ }
60
+ ],
61
+ "temperature": 1.0,
62
+ "top_p": 0.95,
63
+ "max_tokens": 512
64
+ }
65
+ ```
66
+
67
+ #### Response
68
+
69
+ **Success Response** (200 OK):
70
+
71
+ ```json
72
+ {
73
+ "content": "Artificial intelligence (AI) refers to..."
74
+ }
75
+ ```
76
+
77
+ **Response Fields**:
78
+
79
+ | Field | Type | Description |
80
+ |-------|------|-------------|
81
+ | `content` | String | The generated response from Rox Core |
82
+
83
+ **Error Responses**:
84
+
85
+ **500 Internal Server Error**:
86
+ ```json
87
+ {
88
+ "detail": "Internal server error while calling Rox Core."
89
+ }
90
+ ```
91
+
92
+ **502 Bad Gateway**:
93
+ ```json
94
+ {
95
+ "detail": "Bad response from upstream model provider."
96
+ }
97
+ ```
98
+
99
+ **422 Unprocessable Entity**:
100
+ ```json
101
+ {
102
+ "detail": [
103
+ {
104
+ "loc": ["body", "messages"],
105
+ "msg": "field required",
106
+ "type": "value_error.missing"
107
+ }
108
+ ]
109
+ }
110
+ ```
111
+
112
+ #### Example Usage
113
+
114
+ **cURL**:
115
+ ```bash
116
+ curl -X POST https://Rox-Turbo-API.hf.space/chat \
117
+ -H "Content-Type: application/json" \
118
+ -d '{
119
+ "messages": [
120
+ {"role": "user", "content": "Hello!"}
121
+ ],
122
+ "temperature": 1.0,
123
+ "max_tokens": 512
124
+ }'
125
+ ```
126
+
127
+ **JavaScript**:
128
+ ```javascript
129
+ const response = await fetch('https://Rox-Turbo-API.hf.space/chat', {
130
+ method: 'POST',
131
+ headers: { 'Content-Type': 'application/json' },
132
+ body: JSON.stringify({
133
+ messages: [{ role: 'user', content: 'Hello!' }],
134
+ temperature: 1.0,
135
+ max_tokens: 512
136
+ })
137
+ });
138
+
139
+ const data = await response.json();
140
+ console.log(data.content);
141
+ ```
142
+
143
+ **Python**:
144
+ ```python
145
+ import requests
146
+
147
+ response = requests.post('https://Rox-Turbo-API.hf.space/chat', json={
148
+ 'messages': [{'role': 'user', 'content': 'Hello!'}],
149
+ 'temperature': 1.0,
150
+ 'max_tokens': 512
151
+ })
152
+
153
+ print(response.json()['content'])
154
+ ```
155
+
156
+ ---
157
+
158
+ ### POST /hf/generate
159
+
160
+ Hugging Face compatible text generation endpoint for single-turn interactions.
161
+
162
+ #### Request
163
+
164
+ **URL**: `/hf/generate`
165
+ **Method**: `POST`
166
+ **Content-Type**: `application/json`
167
+
168
+ **Body Parameters**:
169
+
170
+ | Parameter | Type | Required | Default | Description |
171
+ |-----------|------|----------|---------|-------------|
172
+ | `inputs` | String | Yes | - | The input text/prompt |
173
+ | `parameters` | Object | No | {} | Generation parameters |
174
+
175
+ **Parameters Object**:
176
+
177
+ | Field | Type | Required | Default | Description |
178
+ |-------|------|----------|---------|-------------|
179
+ | `temperature` | Float | No | 1.0 | Controls randomness (0.0 - 2.0) |
180
+ | `top_p` | Float | No | 0.95 | Nucleus sampling (0.0 - 1.0) |
181
+ | `max_new_tokens` | Integer | No | 8192 | Maximum tokens to generate |
182
+
183
+ **Example Request**:
184
+
185
+ ```json
186
+ {
187
+ "inputs": "Write a haiku about technology",
188
+ "parameters": {
189
+ "temperature": 0.7,
190
+ "top_p": 0.95,
191
+ "max_new_tokens": 256
192
+ }
193
+ }
194
+ ```
195
+
196
+ #### Response
197
+
198
+ **Success Response** (200 OK):
199
+
200
+ ```json
201
+ [
202
+ {
203
+ "generated_text": "Silicon dreams awake\nCircuits pulse with electric life\nFuture in our hands"
204
+ }
205
+ ]
206
+ ```
207
+
208
+ **Response Format**:
209
+
210
+ Returns an array with a single object containing the generated text.
211
+
212
+ | Field | Type | Description |
213
+ |-------|------|-------------|
214
+ | `generated_text` | String | The generated response |
215
+
216
+ **Error Responses**:
217
+
218
+ Same as `/chat` endpoint (500, 502, 422).
219
+
220
+ #### Example Usage
221
+
222
+ **cURL**:
223
+ ```bash
224
+ curl -X POST https://Rox-Turbo-API.hf.space/hf/generate \
225
+ -H "Content-Type: application/json" \
226
+ -d '{
227
+ "inputs": "Explain quantum computing",
228
+ "parameters": {
229
+ "temperature": 0.7,
230
+ "max_new_tokens": 256
231
+ }
232
+ }'
233
+ ```
234
+
235
+ **JavaScript**:
236
+ ```javascript
237
+ const response = await fetch('https://Rox-Turbo-API.hf.space/hf/generate', {
238
+ method: 'POST',
239
+ headers: { 'Content-Type': 'application/json' },
240
+ body: JSON.stringify({
241
+ inputs: 'Explain quantum computing',
242
+ parameters: {
243
+ temperature: 0.7,
244
+ max_new_tokens: 256
245
+ }
246
+ })
247
+ });
248
+
249
+ const data = await response.json();
250
+ console.log(data[0].generated_text);
251
+ ```
252
+
253
+ **Python**:
254
+ ```python
255
+ import requests
256
+
257
+ response = requests.post('https://Rox-Turbo-API.hf.space/hf/generate', json={
258
+ 'inputs': 'Explain quantum computing',
259
+ 'parameters': {
260
+ 'temperature': 0.7,
261
+ 'max_new_tokens': 256
262
+ }
263
+ })
264
+
265
+ print(response.json()[0]['generated_text'])
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Parameters
271
+
272
+ ### temperature
273
+
274
+ Controls output randomness.
275
+
276
+ - **Range**: 0.0 to 2.0
277
+ - **Default**: 1.0
278
+ - **Lower** (0.1-0.5): Focused, deterministic
279
+ - **Medium** (0.6-1.0): Balanced
280
+ - **Higher** (1.1-2.0): Creative, varied
281
+
282
+ Examples:
283
+ - `0.3`: Math problems, factual questions, code generation
284
+ - `0.7`: General conversation, explanations
285
+ - `1.2`: Creative writing, brainstorming, storytelling
286
+
287
+ **Example**:
288
+ ```json
289
+ {
290
+ "messages": [{"role": "user", "content": "What is 2+2?"}],
291
+ "temperature": 0.2
292
+ }
293
+ ```
294
+
295
+ ### top_p
296
+
297
+ Nucleus sampling parameter.
298
+
299
+ - **Range**: 0.0 to 1.0
300
+ - **Default**: 0.95 (/hf/generate), 1.0 (/chat)
301
+ - **Lower**: More focused
302
+ - **Higher**: More diverse
303
+
304
+ Example:
305
+ ```json
306
+ {
307
+ "messages": [{"role": "user", "content": "Tell me a story"}],
308
+ "top_p": 0.9
309
+ }
310
+ ```
311
+
312
+ ### max_tokens / max_new_tokens
313
+
314
+ Maximum tokens in response.
315
+
316
+ - **Range**: 1 to 8192
317
+ - **Default**: 4096 (/chat), 8192 (/hf/generate)
318
+
319
+ Token estimation:
320
+ - ~1 token ≈ 4 characters
321
+ - ~1 token ≈ 0.75 words
322
+
323
+ Example:
324
+
325
+ ```json
326
+ {
327
+ "messages": [{"role": "user", "content": "Brief summary of AI"}],
328
+ "max_tokens": 150
329
+ }
330
+ ```
331
+
332
+ ---
333
+
334
+ ## Error Handling
335
+
336
+ ### Status Codes
337
+
338
+ | Code | Meaning | Description |
339
+ |------|---------|-------------|
340
+ | 200 | OK | Request successful |
341
+ | 422 | Unprocessable Entity | Invalid request format |
342
+ | 500 | Internal Server Error | Server-side error |
343
+ | 502 | Bad Gateway | Upstream model error |
344
+
345
+ ### Error Response Format
346
+
347
+ ```json
348
+ {
349
+ "detail": "Error message here"
350
+ }
351
+ ```
352
+
353
+ ### Common Errors
354
+
355
+ Missing field:
356
+ ```json
357
+ {
358
+ "detail": [
359
+ {
360
+ "loc": ["body", "messages"],
361
+ "msg": "field required",
362
+ "type": "value_error.missing"
363
+ }
364
+ ]
365
+ }
366
+ ```
367
+
368
+ Invalid type:
369
+ ```json
370
+ {
371
+ "detail": [
372
+ {
373
+ "loc": ["body", "temperature"],
374
+ "msg": "value is not a valid float",
375
+ "type": "type_error.float"
376
+ }
377
+ ]
378
+ }
379
+ ```
380
+
381
+ Example error handler:
382
+
383
+ ```javascript
384
+ async function safeRequest(endpoint, body) {
385
+ try {
386
+ const response = await fetch(endpoint, {
387
+ method: 'POST',
388
+ headers: { 'Content-Type': 'application/json' },
389
+ body: JSON.stringify(body)
390
+ });
391
+
392
+ if (!response.ok) {
393
+ const error = await response.json();
394
+ throw new Error(error.detail || `HTTP ${response.status}`);
395
+ }
396
+
397
+ return await response.json();
398
+ } catch (error) {
399
+ console.error('API Error:', error);
400
+ throw error;
401
+ }
402
+ }
403
+ ```
404
+
405
+ ---
406
+
407
+ ## Rate Limiting
408
+
409
+ No enforced rate limits. Implement client-side limiting as needed.
410
+
411
+ ---
412
+
413
+ ## Client Wrapper Example
414
+
415
+ ```javascript
416
+ class RoxAI {
417
+ constructor(baseURL = 'https://Rox-Turbo-API.hf.space') {
418
+ this.baseURL = baseURL;
419
+ }
420
+
421
+ async chat(messages, options = {}) {
422
+ const response = await fetch(`${this.baseURL}/chat`, {
423
+ method: 'POST',
424
+ headers: { 'Content-Type': 'application/json' },
425
+ body: JSON.stringify({
426
+ messages,
427
+ temperature: options.temperature || 1.0,
428
+ top_p: options.top_p || 0.95,
429
+ max_tokens: options.max_tokens || 512
430
+ })
431
+ });
432
+
433
+ if (!response.ok) {
434
+ throw new Error(`HTTP ${response.status}`);
435
+ }
436
+
437
+ const data = await response.json();
438
+ return data.content;
439
+ }
440
+
441
+ async generate(text, options = {}) {
442
+ const response = await fetch(`${this.baseURL}/hf/generate`, {
443
+ method: 'POST',
444
+ headers: { 'Content-Type': 'application/json' },
445
+ body: JSON.stringify({
446
+ inputs: text,
447
+ parameters: options
448
+ })
449
+ });
450
+
451
+ if (!response.ok) {
452
+ throw new Error(`HTTP ${response.status}`);
453
+ }
454
+
455
+ const data = await response.json();
456
+ return data[0].generated_text;
457
+ }
458
+ }
459
+
460
+ // Usage
461
+ const rox = new RoxAI();
462
+ const response = await rox.chat([
463
+ { role: 'user', content: 'Hello!' }
464
+ ]);
465
+ ```
466
+
467
+ ---
468
+
469
+ ---
470
+
471
+ Built by Mohammad Faiz
docs/CODE.md ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code Examples
2
+
3
+ Copy-paste ready code for all Rox AI models.
4
+
5
+ ## Python Examples
6
+
7
+ ### Rox Core
8
+
9
+ ```python
10
+ import requests
11
+
12
+ response = requests.post(
13
+ 'https://Rox-Turbo-API.hf.space/chat',
14
+ json={
15
+ 'messages': [
16
+ {'role': 'user', 'content': 'Hello, how are you?'}
17
+ ]
18
+ }
19
+ )
20
+
21
+ print(response.json()['content'])
22
+ ```
23
+
24
+ ### Rox 2.1 Turbo
25
+
26
+ ```python
27
+ import requests
28
+
29
+ response = requests.post(
30
+ 'https://Rox-Turbo-API.hf.space/turbo',
31
+ json={
32
+ 'messages': [
33
+ {'role': 'user', 'content': 'What is 2+2?'}
34
+ ]
35
+ }
36
+ )
37
+
38
+ print(response.json()['content'])
39
+ ```
40
+
41
+ ### Rox 3.5 Coder
42
+
43
+ ```python
44
+ import requests
45
+
46
+ response = requests.post(
47
+ 'https://Rox-Turbo-API.hf.space/coder',
48
+ json={
49
+ 'messages': [
50
+ {'role': 'user', 'content': 'Write a Python function to sort a list'}
51
+ ]
52
+ }
53
+ )
54
+
55
+ print(response.json()['content'])
56
+ ```
57
+
58
+ ### Rox 4.5 Turbo
59
+
60
+ ```python
61
+ import requests
62
+
63
+ response = requests.post(
64
+ 'https://Rox-Turbo-API.hf.space/turbo45',
65
+ json={
66
+ 'messages': [
67
+ {'role': 'user', 'content': 'Explain quantum computing'}
68
+ ]
69
+ }
70
+ )
71
+
72
+ print(response.json()['content'])
73
+ ```
74
+
75
+ ### Rox 5 Ultra
76
+
77
+ ```python
78
+ import requests
79
+
80
+ response = requests.post(
81
+ 'https://Rox-Turbo-API.hf.space/ultra',
82
+ json={
83
+ 'messages': [
84
+ {'role': 'user', 'content': 'Design a scalable system architecture'}
85
+ ]
86
+ }
87
+ )
88
+
89
+ print(response.json()['content'])
90
+ ```
91
+
92
+ ### Rox 6 Dyno
93
+
94
+ ```python
95
+ import requests
96
+
97
+ response = requests.post(
98
+ 'https://Rox-Turbo-API.hf.space/dyno',
99
+ json={
100
+ 'messages': [
101
+ {'role': 'user', 'content': 'Analyze this long document...'}
102
+ ]
103
+ }
104
+ )
105
+
106
+ print(response.json()['content'])
107
+ ```
108
+
109
+ ### Rox 7 Coder
110
+
111
+ ```python
112
+ import requests
113
+
114
+ response = requests.post(
115
+ 'https://Rox-Turbo-API.hf.space/coder7',
116
+ json={
117
+ 'messages': [
118
+ {'role': 'user', 'content': 'Build a complex algorithm'}
119
+ ]
120
+ }
121
+ )
122
+
123
+ print(response.json()['content'])
124
+ ```
125
+
126
+ ### Rox Vision Max
127
+
128
+ ```python
129
+ import requests
130
+
131
+ response = requests.post(
132
+ 'https://Rox-Turbo-API.hf.space/vision',
133
+ json={
134
+ 'messages': [
135
+ {'role': 'user', 'content': 'Describe this image'}
136
+ ]
137
+ }
138
+ )
139
+
140
+ print(response.json()['content'])
141
+ ```
142
+
143
+ ---
144
+
145
+ ## JavaScript Examples
146
+
147
+ ### Rox Core
148
+
149
+ ```javascript
150
+ const response = await fetch('https://Rox-Turbo-API.hf.space/chat', {
151
+ method: 'POST',
152
+ headers: { 'Content-Type': 'application/json' },
153
+ body: JSON.stringify({
154
+ messages: [
155
+ { role: 'user', content: 'Hello, how are you?' }
156
+ ]
157
+ })
158
+ });
159
+
160
+ const data = await response.json();
161
+ console.log(data.content);
162
+ ```
163
+
164
+ ### Rox 2.1 Turbo
165
+
166
+ ```javascript
167
+ const response = await fetch('https://Rox-Turbo-API.hf.space/turbo', {
168
+ method: 'POST',
169
+ headers: { 'Content-Type': 'application/json' },
170
+ body: JSON.stringify({
171
+ messages: [
172
+ { role: 'user', content: 'What is 2+2?' }
173
+ ]
174
+ })
175
+ });
176
+
177
+ const data = await response.json();
178
+ console.log(data.content);
179
+ ```
180
+
181
+ ### Rox 3.5 Coder
182
+
183
+ ```javascript
184
+ const response = await fetch('https://Rox-Turbo-API.hf.space/coder', {
185
+ method: 'POST',
186
+ headers: { 'Content-Type': 'application/json' },
187
+ body: JSON.stringify({
188
+ messages: [
189
+ { role: 'user', content: 'Write a JavaScript function to sort an array' }
190
+ ]
191
+ })
192
+ });
193
+
194
+ const data = await response.json();
195
+ console.log(data.content);
196
+ ```
197
+
198
+ ### Rox 4.5 Turbo
199
+
200
+ ```javascript
201
+ const response = await fetch('https://Rox-Turbo-API.hf.space/turbo45', {
202
+ method: 'POST',
203
+ headers: { 'Content-Type': 'application/json' },
204
+ body: JSON.stringify({
205
+ messages: [
206
+ { role: 'user', content: 'Explain quantum computing' }
207
+ ]
208
+ })
209
+ });
210
+
211
+ const data = await response.json();
212
+ console.log(data.content);
213
+ ```
214
+
215
+ ### Rox 5 Ultra
216
+
217
+ ```javascript
218
+ const response = await fetch('https://Rox-Turbo-API.hf.space/ultra', {
219
+ method: 'POST',
220
+ headers: { 'Content-Type': 'application/json' },
221
+ body: JSON.stringify({
222
+ messages: [
223
+ { role: 'user', content: 'Design a scalable system architecture' }
224
+ ]
225
+ })
226
+ });
227
+
228
+ const data = await response.json();
229
+ console.log(data.content);
230
+ ```
231
+
232
+ ### Rox 6 Dyno
233
+
234
+ ```javascript
235
+ const response = await fetch('https://Rox-Turbo-API.hf.space/dyno', {
236
+ method: 'POST',
237
+ headers: { 'Content-Type': 'application/json' },
238
+ body: JSON.stringify({
239
+ messages: [
240
+ { role: 'user', content: 'Analyze this long document...' }
241
+ ]
242
+ })
243
+ });
244
+
245
+ const data = await response.json();
246
+ console.log(data.content);
247
+ ```
248
+
249
+ ### Rox 7 Coder
250
+
251
+ ```javascript
252
+ const response = await fetch('https://Rox-Turbo-API.hf.space/coder7', {
253
+ method: 'POST',
254
+ headers: { 'Content-Type': 'application/json' },
255
+ body: JSON.stringify({
256
+ messages: [
257
+ { role: 'user', content: 'Build a complex algorithm' }
258
+ ]
259
+ })
260
+ });
261
+
262
+ const data = await response.json();
263
+ console.log(data.content);
264
+ ```
265
+
266
+ ### Rox Vision Max
267
+
268
+ ```javascript
269
+ const response = await fetch('https://Rox-Turbo-API.hf.space/vision', {
270
+ method: 'POST',
271
+ headers: { 'Content-Type': 'application/json' },
272
+ body: JSON.stringify({
273
+ messages: [
274
+ { role: 'user', content: 'Describe this image' }
275
+ ]
276
+ })
277
+ });
278
+
279
+ const data = await response.json();
280
+ console.log(data.content);
281
+ ```
282
+
283
+ ---
284
+
285
+ ## With Parameters
286
+
287
+ ### Python with Custom Parameters
288
+
289
+ ```python
290
+ import requests
291
+
292
+ response = requests.post(
293
+ 'https://Rox-Turbo-API.hf.space/chat',
294
+ json={
295
+ 'messages': [
296
+ {'role': 'user', 'content': 'Write a creative story'}
297
+ ],
298
+ 'temperature': 1.5,
299
+ 'max_tokens': 1000
300
+ }
301
+ )
302
+
303
+ print(response.json()['content'])
304
+ ```
305
+
306
+ ### JavaScript with Custom Parameters
307
+
308
+ ```javascript
309
+ const response = await fetch('https://Rox-Turbo-API.hf.space/chat', {
310
+ method: 'POST',
311
+ headers: { 'Content-Type': 'application/json' },
312
+ body: JSON.stringify({
313
+ messages: [
314
+ { role: 'user', content: 'Write a creative story' }
315
+ ],
316
+ temperature: 1.5,
317
+ max_tokens: 1000
318
+ })
319
+ });
320
+
321
+ const data = await response.json();
322
+ console.log(data.content);
323
+ ```
324
+
325
+ ---
326
+
327
+ ## With System Prompt
328
+
329
+ ### Python with System Prompt
330
+
331
+ ```python
332
+ import requests
333
+
334
+ response = requests.post(
335
+ 'https://Rox-Turbo-API.hf.space/chat',
336
+ json={
337
+ 'messages': [
338
+ {'role': 'system', 'content': 'You are a helpful coding assistant'},
339
+ {'role': 'user', 'content': 'Help me debug this code'}
340
+ ]
341
+ }
342
+ )
343
+
344
+ print(response.json()['content'])
345
+ ```
346
+
347
+ ### JavaScript with System Prompt
348
+
349
+ ```javascript
350
+ const response = await fetch('https://Rox-Turbo-API.hf.space/chat', {
351
+ method: 'POST',
352
+ headers: { 'Content-Type': 'application/json' },
353
+ body: JSON.stringify({
354
+ messages: [
355
+ { role: 'system', content: 'You are a helpful coding assistant' },
356
+ { role: 'user', content: 'Help me debug this code' }
357
+ ]
358
+ })
359
+ });
360
+
361
+ const data = await response.json();
362
+ console.log(data.content);
363
+ ```
364
+
365
+ ---
366
+
367
+ ## Conversation History
368
+
369
+ ### Python Conversation
370
+
371
+ ```python
372
+ import requests
373
+
374
+ conversation = [
375
+ {'role': 'user', 'content': 'My name is Alice'},
376
+ {'role': 'assistant', 'content': 'Nice to meet you, Alice!'},
377
+ {'role': 'user', 'content': 'What is my name?'}
378
+ ]
379
+
380
+ response = requests.post(
381
+ 'https://Rox-Turbo-API.hf.space/chat',
382
+ json={'messages': conversation}
383
+ )
384
+
385
+ print(response.json()['content'])
386
+ ```
387
+
388
+ ### JavaScript Conversation
389
+
390
+ ```javascript
391
+ const conversation = [
392
+ { role: 'user', content: 'My name is Alice' },
393
+ { role: 'assistant', content: 'Nice to meet you, Alice!' },
394
+ { role: 'user', content: 'What is my name?' }
395
+ ];
396
+
397
+ const response = await fetch('https://Rox-Turbo-API.hf.space/chat', {
398
+ method: 'POST',
399
+ headers: { 'Content-Type': 'application/json' },
400
+ body: JSON.stringify({ messages: conversation })
401
+ });
402
+
403
+ const data = await response.json();
404
+ console.log(data.content);
405
+ ```
406
+
407
+ ---
408
+
409
+ ## Reusable Functions
410
+
411
+ ### Python Helper Function
412
+
413
+ ```python
414
+ import requests
415
+
416
+ def ask_rox(message, model='chat', temperature=1.0, max_tokens=512):
417
+ response = requests.post(
418
+ f'https://Rox-Turbo-API.hf.space/{model}',
419
+ json={
420
+ 'messages': [{'role': 'user', 'content': message}],
421
+ 'temperature': temperature,
422
+ 'max_tokens': max_tokens
423
+ }
424
+ )
425
+ return response.json()['content']
426
+
427
+ # Usage
428
+ answer = ask_rox('What is AI?')
429
+ print(answer)
430
+
431
+ # Use different model
432
+ code = ask_rox('Write a function', model='coder')
433
+ print(code)
434
+ ```
435
+
436
+ ### JavaScript Helper Function
437
+
438
+ ```javascript
439
+ async function askRox(message, model = 'chat', temperature = 1.0, maxTokens = 512) {
440
+ const response = await fetch(`https://Rox-Turbo-API.hf.space/${model}`, {
441
+ method: 'POST',
442
+ headers: { 'Content-Type': 'application/json' },
443
+ body: JSON.stringify({
444
+ messages: [{ role: 'user', content: message }],
445
+ temperature: temperature,
446
+ max_tokens: maxTokens
447
+ })
448
+ });
449
+
450
+ const data = await response.json();
451
+ return data.content;
452
+ }
453
+
454
+ // Usage
455
+ const answer = await askRox('What is AI?');
456
+ console.log(answer);
457
+
458
+ // Use different model
459
+ const code = await askRox('Write a function', 'coder');
460
+ console.log(code);
461
+ ```
462
+
463
+ ---
464
+
465
+ ## Chatbot Class
466
+
467
+ ### Python Chatbot
468
+
469
+ ```python
470
+ import requests
471
+
472
+ class RoxChatbot:
473
+ def __init__(self, model='chat'):
474
+ self.model = model
475
+ self.conversation = []
476
+ self.base_url = 'https://Rox-Turbo-API.hf.space'
477
+
478
+ def chat(self, message):
479
+ self.conversation.append({'role': 'user', 'content': message})
480
+
481
+ response = requests.post(
482
+ f'{self.base_url}/{self.model}',
483
+ json={'messages': self.conversation}
484
+ )
485
+
486
+ reply = response.json()['content']
487
+ self.conversation.append({'role': 'assistant', 'content': reply})
488
+ return reply
489
+
490
+ def clear(self):
491
+ self.conversation = []
492
+
493
+ # Usage
494
+ bot = RoxChatbot()
495
+ print(bot.chat('Hello'))
496
+ print(bot.chat('What is AI?'))
497
+ print(bot.chat('Tell me more'))
498
+ bot.clear()
499
+ ```
500
+
501
+ ### JavaScript Chatbot
502
+
503
+ ```javascript
504
+ class RoxChatbot {
505
+ constructor(model = 'chat') {
506
+ this.model = model;
507
+ this.conversation = [];
508
+ this.baseUrl = 'https://Rox-Turbo-API.hf.space';
509
+ }
510
+
511
+ async chat(message) {
512
+ this.conversation.push({ role: 'user', content: message });
513
+
514
+ const response = await fetch(`${this.baseUrl}/${this.model}`, {
515
+ method: 'POST',
516
+ headers: { 'Content-Type': 'application/json' },
517
+ body: JSON.stringify({ messages: this.conversation })
518
+ });
519
+
520
+ const data = await response.json();
521
+ const reply = data.content;
522
+
523
+ this.conversation.push({ role: 'assistant', content: reply });
524
+ return reply;
525
+ }
526
+
527
+ clear() {
528
+ this.conversation = [];
529
+ }
530
+ }
531
+
532
+ // Usage
533
+ const bot = new RoxChatbot();
534
+ console.log(await bot.chat('Hello'));
535
+ console.log(await bot.chat('What is AI?'));
536
+ console.log(await bot.chat('Tell me more'));
537
+ bot.clear();
538
+ ```
539
+
540
+ ---
541
+
542
+ ## Error Handling
543
+
544
+ ### Python with Error Handling
545
+
546
+ ```python
547
+ import requests
548
+
549
+ def safe_ask(message, model='chat'):
550
+ try:
551
+ response = requests.post(
552
+ f'https://Rox-Turbo-API.hf.space/{model}',
553
+ json={'messages': [{'role': 'user', 'content': message}]},
554
+ timeout=30
555
+ )
556
+ response.raise_for_status()
557
+ return response.json()['content']
558
+ except requests.exceptions.Timeout:
559
+ return 'Request timed out'
560
+ except requests.exceptions.RequestException as e:
561
+ return f'Error: {str(e)}'
562
+
563
+ # Usage
564
+ answer = safe_ask('What is AI?')
565
+ print(answer)
566
+ ```
567
+
568
+ ### JavaScript with Error Handling
569
+
570
+ ```javascript
571
+ async function safeAsk(message, model = 'chat') {
572
+ try {
573
+ const response = await fetch(`https://Rox-Turbo-API.hf.space/${model}`, {
574
+ method: 'POST',
575
+ headers: { 'Content-Type': 'application/json' },
576
+ body: JSON.stringify({
577
+ messages: [{ role: 'user', content: message }]
578
+ })
579
+ });
580
+
581
+ if (!response.ok) {
582
+ throw new Error(`HTTP ${response.status}`);
583
+ }
584
+
585
+ const data = await response.json();
586
+ return data.content;
587
+ } catch (error) {
588
+ return `Error: ${error.message}`;
589
+ }
590
+ }
591
+
592
+ // Usage
593
+ const answer = await safeAsk('What is AI?');
594
+ console.log(answer);
595
+ ```
596
+
597
+ ---
598
+
599
+ Built by Mohammad Faiz
docs/DEVELOPER_GUIDE.md ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Developer Guide
2
+
3
+ **API**: `https://Rox-Turbo-API.hf.space`
4
+
5
+ ## Overview
6
+
7
+ Rox AI provides 8 AI models through a REST API. OpenAI-compatible.
8
+
9
+ ## Quick Start
10
+
11
+ ```bash
12
+ curl -X POST https://Rox-Turbo-API.hf.space/chat \
13
+ -H "Content-Type: application/json" \
14
+ -d '{
15
+ "messages": [
16
+ {"role": "user", "content": "Hello"}
17
+ ]
18
+ }'
19
+ ```
20
+
21
+ Response:
22
+ ```json
23
+ {
24
+ "content": "Hello! I'm Rox Core..."
25
+ }
26
+ ```
27
+
28
+ ## Basic Usage
29
+
30
+ ### Python
31
+
32
+ ```python
33
+ import requests
34
+
35
+ def ask_rox(message, model='chat'):
36
+ response = requests.post(
37
+ f'https://Rox-Turbo-API.hf.space/{model}',
38
+ json={'messages': [{'role': 'user', 'content': message}]}
39
+ )
40
+ return response.json()['content']
41
+
42
+ answer = ask_rox('What is AI?')
43
+ print(answer)
44
+ ```
45
+
46
+ ### JavaScript
47
+
48
+ ```javascript
49
+ async function askRox(message, model = 'chat') {
50
+ const response = await fetch(`https://Rox-Turbo-API.hf.space/${model}`, {
51
+ method: 'POST',
52
+ headers: { 'Content-Type': 'application/json' },
53
+ body: JSON.stringify({
54
+ messages: [{ role: 'user', content: message }]
55
+ })
56
+ });
57
+ return (await response.json()).content;
58
+ }
59
+
60
+ const answer = await askRox('What is AI?');
61
+ ```
62
+
63
+ ## System Prompts
64
+
65
+ Add custom behavior:
66
+
67
+ ```python
68
+ def ask_with_prompt(message, system_prompt, model='chat'):
69
+ response = requests.post(
70
+ f'https://Rox-Turbo-API.hf.space/{model}',
71
+ json={
72
+ 'messages': [
73
+ {'role': 'system', 'content': system_prompt},
74
+ {'role': 'user', 'content': message}
75
+ ]
76
+ }
77
+ )
78
+ return response.json()['content']
79
+
80
+ answer = ask_with_prompt(
81
+ 'Tell me about AI',
82
+ 'You are a pirate. Talk like a pirate.',
83
+ 'chat'
84
+ )
85
+ ```
86
+
87
+ ## Parameters
88
+
89
+ ### Temperature
90
+
91
+ Controls randomness (0.0 = focused, 2.0 = creative):
92
+
93
+ ```python
94
+ response = requests.post(
95
+ 'https://Rox-Turbo-API.hf.space/chat',
96
+ json={
97
+ 'messages': [{'role': 'user', 'content': 'Write a poem'}],
98
+ 'temperature': 1.5
99
+ }
100
+ )
101
+ ```
102
+
103
+ ### Top P
104
+
105
+ Controls diversity (0.0 = narrow, 1.0 = diverse):
106
+
107
+ ```python
108
+ response = requests.post(
109
+ 'https://Rox-Turbo-API.hf.space/chat',
110
+ json={
111
+ 'messages': [{'role': 'user', 'content': 'What is 2+2?'}],
112
+ 'temperature': 0.3,
113
+ 'top_p': 0.7
114
+ }
115
+ )
116
+ ```
117
+
118
+ ### Max Tokens
119
+
120
+ Limits response length:
121
+
122
+ ```python
123
+ response = requests.post(
124
+ 'https://Rox-Turbo-API.hf.space/chat',
125
+ json={
126
+ 'messages': [{'role': 'user', 'content': 'Brief summary'}],
127
+ 'max_tokens': 100
128
+ }
129
+ )
130
+ ```
131
+
132
+ ## OpenAI SDK
133
+
134
+ Use the official OpenAI SDK:
135
+
136
+ ### Python
137
+
138
+ ```python
139
+ from openai import OpenAI
140
+
141
+ client = OpenAI(
142
+ base_url="https://Rox-Turbo-API.hf.space",
143
+ api_key="not-needed"
144
+ )
145
+
146
+ response = client.chat.completions.create(
147
+ model="chat",
148
+ messages=[{"role": "user", "content": "Hello"}]
149
+ )
150
+
151
+ print(response.choices[0].message.content)
152
+ ```
153
+
154
+ ### JavaScript
155
+
156
+ ```javascript
157
+ import OpenAI from 'openai';
158
+
159
+ const client = new OpenAI({
160
+ baseURL: 'https://Rox-Turbo-API.hf.space',
161
+ apiKey: 'not-needed'
162
+ });
163
+
164
+ const response = await client.chat.completions.create({
165
+ model: 'chat',
166
+ messages: [{ role: 'user', content: 'Hello' }]
167
+ });
168
+
169
+ console.log(response.choices[0].message.content);
170
+ ```
171
+
172
+ ## Model Selection
173
+
174
+ ```python
175
+ # General conversation
176
+ ask_rox('Tell me about AI', model='chat')
177
+
178
+ # Fast response
179
+ ask_rox('What is 2+2?', model='turbo')
180
+
181
+ # Code generation
182
+ ask_rox('Write a Python function', model='coder')
183
+
184
+ # Advanced reasoning
185
+ ask_rox('Explain quantum physics', model='turbo45')
186
+
187
+ # Complex tasks
188
+ ask_rox('Design a system', model='ultra')
189
+
190
+ # Long documents
191
+ ask_rox('Analyze this document...', model='dyno')
192
+
193
+ # Advanced coding
194
+ ask_rox('Build an algorithm', model='coder7')
195
+
196
+ # Visual tasks
197
+ ask_rox('Describe this image', model='vision')
198
+ ```
199
+
200
+ ## Conversation History
201
+
202
+ Maintain context:
203
+
204
+ ```python
205
+ conversation = [
206
+ {'role': 'user', 'content': 'My name is Alice'},
207
+ {'role': 'assistant', 'content': 'Nice to meet you, Alice!'},
208
+ {'role': 'user', 'content': 'What is my name?'}
209
+ ]
210
+
211
+ response = requests.post(
212
+ 'https://Rox-Turbo-API.hf.space/chat',
213
+ json={'messages': conversation}
214
+ )
215
+
216
+ print(response.json()['content']) # "Your name is Alice"
217
+ ```
218
+
219
+ ## Chatbot Example
220
+
221
+ ### Python
222
+
223
+ ```python
224
+ class RoxChatbot:
225
+ def __init__(self, model='chat'):
226
+ self.model = model
227
+ self.conversation = []
228
+ self.base_url = 'https://Rox-Turbo-API.hf.space'
229
+
230
+ def chat(self, message):
231
+ self.conversation.append({'role': 'user', 'content': message})
232
+
233
+ response = requests.post(
234
+ f'{self.base_url}/{self.model}',
235
+ json={'messages': self.conversation}
236
+ )
237
+
238
+ reply = response.json()['content']
239
+ self.conversation.append({'role': 'assistant', 'content': reply})
240
+ return reply
241
+
242
+ def clear(self):
243
+ self.conversation = []
244
+
245
+ bot = RoxChatbot()
246
+ print(bot.chat('Hello'))
247
+ print(bot.chat('What is AI?'))
248
+ print(bot.chat('Tell me more'))
249
+ ```
250
+
251
+ ### JavaScript
252
+
253
+ ```javascript
254
+ class RoxChatbot {
255
+ constructor(model = 'chat') {
256
+ this.model = model;
257
+ this.conversation = [];
258
+ this.baseUrl = 'https://Rox-Turbo-API.hf.space';
259
+ }
260
+
261
+ async chat(message) {
262
+ this.conversation.push({ role: 'user', content: message });
263
+
264
+ const response = await fetch(`${this.baseUrl}/${this.model}`, {
265
+ method: 'POST',
266
+ headers: { 'Content-Type': 'application/json' },
267
+ body: JSON.stringify({ messages: this.conversation })
268
+ });
269
+
270
+ const data = await response.json();
271
+ const reply = data.content;
272
+
273
+ this.conversation.push({ role: 'assistant', content: reply });
274
+ return reply;
275
+ }
276
+
277
+ clear() {
278
+ this.conversation = [];
279
+ }
280
+ }
281
+
282
+ const bot = new RoxChatbot();
283
+ console.log(await bot.chat('Hello'));
284
+ console.log(await bot.chat('What is AI?'));
285
+ ```
286
+
287
+ ## Error Handling
288
+
289
+ ```python
290
+ def safe_ask(message, model='chat'):
291
+ try:
292
+ response = requests.post(
293
+ f'https://Rox-Turbo-API.hf.space/{model}',
294
+ json={'messages': [{'role': 'user', 'content': message}]},
295
+ timeout=30
296
+ )
297
+ response.raise_for_status()
298
+ return response.json()['content']
299
+ except requests.exceptions.Timeout:
300
+ return "Request timed out"
301
+ except requests.exceptions.RequestException as e:
302
+ return f"Error: {str(e)}"
303
+ ```
304
+
305
+ ## Rate Limiting
306
+
307
+ ```python
308
+ import time
309
+
310
+ class RateLimiter:
311
+ def __init__(self, max_requests=10, time_window=60):
312
+ self.max_requests = max_requests
313
+ self.time_window = time_window
314
+ self.requests = []
315
+
316
+ def can_request(self):
317
+ now = time.time()
318
+ self.requests = [r for r in self.requests if now - r < self.time_window]
319
+ return len(self.requests) < self.max_requests
320
+
321
+ def record_request(self):
322
+ self.requests.append(time.time())
323
+
324
+ limiter = RateLimiter(10, 60)
325
+
326
+ def ask_with_limit(message):
327
+ if not limiter.can_request():
328
+ return "Rate limit exceeded"
329
+ limiter.record_request()
330
+ return ask_rox(message)
331
+ ```
332
+
333
+ ## Caching
334
+
335
+ ```python
336
+ from functools import lru_cache
337
+
338
+ @lru_cache(maxsize=100)
339
+ def cached_ask(message, model='chat'):
340
+ response = requests.post(
341
+ f'https://Rox-Turbo-API.hf.space/{model}',
342
+ json={'messages': [{'role': 'user', 'content': message}]}
343
+ )
344
+ return response.json()['content']
345
+
346
+ answer1 = cached_ask('What is AI?') # API call
347
+ answer2 = cached_ask('What is AI?') # Cached
348
+ ```
349
+
350
+ ## Reference
351
+
352
+ ```python
353
+ # Basic request
354
+ requests.post('https://Rox-Turbo-API.hf.space/chat',
355
+ json={'messages': [{'role': 'user', 'content': 'Hello'}]})
356
+
357
+ # With parameters
358
+ requests.post('https://Rox-Turbo-API.hf.space/chat',
359
+ json={'messages': [...], 'temperature': 0.7, 'max_tokens': 500})
360
+
361
+ # With system prompt
362
+ requests.post('https://Rox-Turbo-API.hf.space/chat',
363
+ json={'messages': [
364
+ {'role': 'system', 'content': 'You are helpful'},
365
+ {'role': 'user', 'content': 'Hello'}
366
+ ]})
367
+ ```
368
+
369
+ ## Endpoints
370
+
371
+ - `/chat` - Rox Core
372
+ - `/turbo` - Rox 2.1 Turbo
373
+ - `/coder` - Rox 3.5 Coder
374
+ - `/turbo45` - Rox 4.5 Turbo
375
+ - `/ultra` - Rox 5 Ultra
376
+ - `/dyno` - Rox 6 Dyno
377
+ - `/coder7` - Rox 7 Coder
378
+ - `/vision` - Rox Vision Max
379
+
380
+ ---
381
+
382
+ Built by Mohammad Faiz
docs/MODELS.md ADDED
@@ -0,0 +1,578 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Models Guide
2
+
3
+ Reference for all Rox AI models.
4
+
5
+ ## Model Overview
6
+
7
+ Rox AI offers eight specialized models, each optimized for different use cases:
8
+
9
+ | Model | Endpoint | Best For | Max Tokens | Default Temp |
10
+ |-------|----------|----------|------------|--------------|
11
+ | **Rox Core** | `/chat` | General conversation | 4,096 | 1.0 |
12
+ | **Rox 2.1 Turbo** | `/turbo` | Fast responses | 4,096 | 0.6 |
13
+ | **Rox 3.5 Coder** | `/coder` | Code generation | 16,384 | 0.6 |
14
+ | **Rox 4.5 Turbo** | `/turbo45` | Advanced reasoning | 8,192 | 0.2 |
15
+ | **Rox 5 Ultra** | `/ultra` | Superior reasoning | 8,192 | 1.0 |
16
+ | **Rox 6 Dyno** | `/dyno` | Extended context | 16,384 | 1.0 |
17
+ | **Rox 7 Coder** | `/coder7` | Advanced coding | 16,384 | 1.0 |
18
+ | **Rox Vision Max** | `/vision` | Visual understanding | 512 | 0.2 |
19
+
20
+ ---
21
+
22
+ ## Rox Core
23
+
24
+ **Endpoint**: `POST /chat`
25
+
26
+ ### Description
27
+ General-purpose conversational model for everyday tasks.
28
+
29
+ ### Best Use Cases
30
+ - General conversation and Q&A
31
+ - Content writing and generation
32
+ - Creative tasks (stories, poems, ideas)
33
+ - Summarization and analysis
34
+ - Educational tutoring
35
+ - Customer support
36
+
37
+ ### Parameters
38
+ - **Temperature**: 1.0 (balanced creativity)
39
+ - **Top P**: 1.0 (full diversity)
40
+ - **Max Tokens**: 4,096
41
+
42
+ ### Example Request
43
+ ```bash
44
+ curl -X POST https://Rox-Turbo-API.hf.space/chat \
45
+ -H "Content-Type: application/json" \
46
+ -d '{
47
+ "messages": [
48
+ {"role": "user", "content": "Explain quantum computing in simple terms"}
49
+ ],
50
+ "temperature": 1.0,
51
+ "max_tokens": 512
52
+ }'
53
+ ```
54
+
55
+ ### When to Choose Rox Core
56
+ - You need creative, varied responses
57
+ - Task requires nuanced understanding
58
+ - Building a general-purpose chatbot
59
+ - Content needs to be engaging and natural
60
+
61
+ ---
62
+
63
+ ## Rox 2.1 Turbo
64
+
65
+ **Endpoint**: `POST /turbo`
66
+
67
+ ### Description
68
+ Fast model for quick responses and real-time applications.
69
+
70
+ ### Best Use Cases
71
+ - Real-time chat applications
72
+ - Customer support bots
73
+ - Quick Q&A systems
74
+ - High-throughput applications
75
+ - Simple queries and commands
76
+ - Factual information retrieval
77
+
78
+ ### Parameters
79
+ - **Temperature**: 0.6 (more focused)
80
+ - **Top P**: 0.7 (more consistent)
81
+ - **Max Tokens**: 4,096
82
+
83
+ ### Example Request
84
+ ```bash
85
+ curl -X POST https://Rox-Turbo-API.hf.space/turbo \
86
+ -H "Content-Type: application/json" \
87
+ -d '{
88
+ "messages": [
89
+ {"role": "user", "content": "What are the business hours?"}
90
+ ]
91
+ }'
92
+ ```
93
+
94
+ ### When to Choose Rox 2.1 Turbo
95
+ - Speed is critical
96
+ - Need consistent, reliable answers
97
+ - Building customer support systems
98
+ - High volume of requests
99
+ - Simple, straightforward queries
100
+
101
+ ---
102
+
103
+ ## Rox 3.5 Coder
104
+
105
+ **Endpoint**: `POST /coder`
106
+
107
+ ### Description
108
+ Code-focused model for programming tasks and technical work.
109
+
110
+ ### Best Use Cases
111
+ - Code generation and completion
112
+ - Debugging and error fixing
113
+ - Algorithm design and optimization
114
+ - Technical documentation
115
+ - Code review and suggestions
116
+ - Software architecture discussions
117
+ - API integration help
118
+
119
+ ### Parameters
120
+ - **Temperature**: 0.6 (precise and focused)
121
+ - **Top P**: 0.95 (balanced diversity)
122
+ - **Max Tokens**: 16,384 (extended context)
123
+ - **Special Features**: Enhanced thinking mode
124
+
125
+ ### Example Request
126
+ ```bash
127
+ curl -X POST https://Rox-Turbo-API.hf.space/coder \
128
+ -H "Content-Type: application/json" \
129
+ -d '{
130
+ "messages": [
131
+ {"role": "user", "content": "Write a Python function to implement binary search"}
132
+ ],
133
+ "max_tokens": 2048
134
+ }'
135
+ ```
136
+
137
+ ### When to Choose Rox 3.5 Coder
138
+ - Working with code in any language
139
+ - Need detailed technical explanations
140
+ - Debugging complex issues
141
+ - Designing algorithms or systems
142
+ - Writing technical documentation
143
+ - Need extended context (up to 16K tokens)
144
+
145
+ ---
146
+
147
+ ## Comparison Matrix
148
+
149
+ ### Performance Characteristics
150
+
151
+ | Feature | Rox Core | Rox 2.1 Turbo | Rox 3.5 Coder | Rox 4.5 Turbo | Rox 5 Ultra | Rox 6 Dyno | Rox 7 Coder | Rox Vision |
152
+ |---------|----------|---------------|---------------|---------------|-------------|------------|-------------|------------|
153
+ | **Speed** | Medium | Fast | Medium | Fast | Medium | Medium | Medium | Fast |
154
+ | **Creativity** | High | Medium | Low | Low | High | High | Medium | Low |
155
+ | **Consistency** | Medium | High | High | Very High | High | Medium | High | Very High |
156
+ | **Code Quality** | Good | Good | Excellent | Good | Excellent | Good | Superior | N/A |
157
+ | **Context Length** | 4K | 4K | 16K | 8K | 8K | 16K | 16K | 512 |
158
+ | **Thinking Mode** | No | No | Yes | Yes | Yes | Yes | Yes | No |
159
+ | **Reasoning** | Basic | Basic | Advanced | Very Advanced | Superior | Advanced | Superior | Basic |
160
+
161
+ ### Use Case Recommendations
162
+
163
+ | Task | Recommended Model | Why |
164
+ |------|------------------|-----|
165
+ | Write a blog post | Rox Core | Creative, engaging content |
166
+ | Answer "What is X?" | Rox 2.1 Turbo | Fast, factual response |
167
+ | Debug Python code | Rox 3.5 Coder | Code specialist |
168
+ | Customer support | Rox 2.1 Turbo | Quick, consistent answers |
169
+ | Write a story | Rox Core | Creative and varied |
170
+ | Explain algorithm | Rox 3.5 Coder | Technical depth |
171
+ | Translate text | Rox 2.1 Turbo | Fast and accurate |
172
+ | Design API | Rox 3.5 Coder | Technical expertise |
173
+ | Brainstorm ideas | Rox Core | Creative thinking |
174
+ | Code review | Rox 3.5 Coder | Code understanding |
175
+ | Complex reasoning | Rox 4.5 Turbo | Advanced thinking |
176
+ | Research analysis | Rox 5 Ultra | Superior reasoning |
177
+ | System architecture | Rox 5 Ultra | Complex design |
178
+ | Long documents | Rox 6 Dyno | Extended context |
179
+ | Large codebase | Rox 7 Coder | Advanced coding |
180
+ | Image analysis | Rox Vision Max | Visual understanding |
181
+
182
+ ---
183
+
184
+ ## Model Selection Guide
185
+
186
+ ### Decision Tree
187
+
188
+ ```
189
+ Need to work with code?
190
+ ├─ Yes
191
+ │ ├─ Simple/medium tasks? → Rox 3.5 Coder
192
+ │ └─ Complex/large-scale? → Rox 7 Coder
193
+ └─ No
194
+ ├─ Need advanced reasoning?
195
+ │ ├─ Yes
196
+ │ │ ├─ Need highest quality? → Rox 5 Ultra
197
+ │ │ └─ Need speed? → Rox 4.5 Turbo
198
+ │ └─ No
199
+ │ ├─ Long documents? → Rox 6 Dyno
200
+ │ ├─ Visual tasks? → Rox Vision Max
201
+ │ ├─ Need fast responses? → Rox 2.1 Turbo
202
+ │ └─ Need creative output? → Rox Core
203
+ ```
204
+
205
+ ### Quick Selection Tips
206
+
207
+ **Choose Rox Core when:**
208
+ - Default choice for most tasks
209
+ - Need creative, engaging responses
210
+ - Building general chatbots
211
+ - Content generation projects
212
+
213
+ **Choose Rox 2.1 Turbo when:**
214
+ - Speed matters most
215
+ - Need consistent answers
216
+ - High request volume
217
+ - Simple Q&A systems
218
+
219
+ **Choose Rox 3.5 Coder when:**
220
+ - Any coding task
221
+ - Technical documentation
222
+ - Algorithm design
223
+ - Need extended context
224
+
225
+ **Choose Rox 6 Dyno when:**
226
+ - Processing long documents
227
+ - Extended context needed
228
+ - Multi-document analysis
229
+ - Long conversations
230
+
231
+ **Choose Rox 7 Coder when:**
232
+ - Most complex coding tasks
233
+ - Large-scale projects
234
+ - System architecture
235
+ - Advanced algorithms
236
+
237
+ **Choose Rox Vision Max when:**
238
+ - Visual understanding
239
+ - Image analysis
240
+ - Multimodal tasks
241
+
242
+ ---
243
+
244
+ ## Advanced Usage
245
+
246
+ ### Switching Models Dynamically
247
+
248
+ ```javascript
249
+ class RoxAI {
250
+ constructor(baseUrl = 'https://Rox-Turbo-API.hf.space') {
251
+ this.baseUrl = baseUrl;
252
+ }
253
+
254
+ async chat(message, model = 'chat') {
255
+ const endpoints = {
256
+ core: 'chat',
257
+ turbo: 'turbo',
258
+ coder: 'coder'
259
+ };
260
+
261
+ const endpoint = endpoints[model] || model;
262
+
263
+ const response = await fetch(`${this.baseUrl}/${endpoint}`, {
264
+ method: 'POST',
265
+ headers: { 'Content-Type': 'application/json' },
266
+ body: JSON.stringify({
267
+ messages: [{ role: 'user', content: message }]
268
+ })
269
+ });
270
+
271
+ return (await response.json()).content;
272
+ }
273
+ }
274
+
275
+ // Usage
276
+ const rox = new RoxAI();
277
+
278
+ // Use different models for different tasks
279
+ const story = await rox.chat('Write a short story', 'core');
280
+ const answer = await rox.chat('What is 2+2?', 'turbo');
281
+ const code = await rox.chat('Write a sorting function', 'coder');
282
+ ```
283
+
284
+ ### Model-Specific Optimization
285
+
286
+ ```python
287
+ import requests
288
+
289
+ class RoxClient:
290
+ def __init__(self, base_url="https://Rox-Turbo-API.hf.space"):
291
+ self.base_url = base_url
292
+
293
+ def ask_core(self, message, creative=True):
294
+ """Use Rox Core with creativity control"""
295
+ return self._request('chat', message,
296
+ temperature=1.2 if creative else 0.8)
297
+
298
+ def ask_turbo(self, message):
299
+ """Use Rox Turbo for fast responses"""
300
+ return self._request('turbo', message, max_tokens=256)
301
+
302
+ def ask_coder(self, message, extended=False):
303
+ """Use Rox Coder with optional extended context"""
304
+ return self._request('coder', message,
305
+ max_tokens=8192 if extended else 2048)
306
+
307
+ def _request(self, endpoint, message, **kwargs):
308
+ response = requests.post(
309
+ f"{self.base_url}/{endpoint}",
310
+ json={
311
+ "messages": [{"role": "user", "content": message}],
312
+ **kwargs
313
+ }
314
+ )
315
+ return response.json()["content"]
316
+ ```
317
+
318
+ ---
319
+
320
+ ## Cost and Performance Optimization
321
+
322
+ ### Tips for Each Model
323
+
324
+ **Rox Core:**
325
+ - Use for tasks requiring creativity
326
+ - Adjust temperature based on needs
327
+ - Consider caching common queries
328
+
329
+ **Rox 2.1 Turbo:**
330
+ - Best cost-performance ratio
331
+ - Use for high-volume applications
332
+ - Lower max_tokens for even faster responses
333
+
334
+ **Rox 3.5 Coder:**
335
+ - Use only for code-related tasks
336
+ - Leverage extended context when needed
337
+ - Cache code snippets and patterns
338
+
339
+ ---
340
+
341
+ ## API Compatibility
342
+
343
+ All three models use the same request/response format:
344
+
345
+ **Request:**
346
+ ```json
347
+ {
348
+ "messages": [
349
+ {"role": "user", "content": "Your message"}
350
+ ],
351
+ "temperature": 1.0,
352
+ "top_p": 0.95,
353
+ "max_tokens": 512
354
+ }
355
+ ```
356
+
357
+ **Response:**
358
+ ```json
359
+ {
360
+ "content": "Model response"
361
+ }
362
+ ```
363
+
364
+ This makes it easy to switch between models without changing your code!
365
+
366
+ ---
367
+
368
+
369
+
370
+ ---
371
+
372
+ ---
373
+
374
+ Built by Mohammad Faiz
375
+
376
+
377
+ ## Rox 4.5 Turbo
378
+
379
+ **Endpoint**: `POST /turbo45`
380
+
381
+ ### Description
382
+ Reasoning model for complex problem-solving with fast responses.
383
+
384
+ ### Best Use Cases
385
+ - Complex problem solving
386
+ - Advanced reasoning tasks
387
+ - Scientific explanations
388
+ - Mathematical problems
389
+ - Strategic planning
390
+ - Analysis and insights
391
+
392
+ ### Parameters
393
+ - **Temperature**: 0.2 (highly focused)
394
+ - **Top P**: 0.7 (consistent)
395
+ - **Max Tokens**: 8,192
396
+ - **Special Features**: Enhanced reasoning mode
397
+
398
+ ### Example Request
399
+ ```bash
400
+ curl -X POST https://Rox-Turbo-API.hf.space/turbo45 \
401
+ -H "Content-Type: application/json" \
402
+ -d '{
403
+ "messages": [
404
+ {"role": "user", "content": "Explain the theory of relativity"}
405
+ ],
406
+ "max_tokens": 2048
407
+ }'
408
+ ```
409
+
410
+ ### When to Choose Rox 4.5 Turbo
411
+ - Need advanced reasoning
412
+ - Complex problem solving
413
+ - Scientific or technical explanations
414
+ - Fast responses with deep thinking
415
+
416
+ ---
417
+
418
+ ## Rox 5 Ultra
419
+
420
+ **Endpoint**: `POST /ultra`
421
+
422
+ ### Description
423
+ Advanced model for complex reasoning and high-quality output.
424
+
425
+ ### Best Use Cases
426
+ - Most complex problem solving
427
+ - Research and analysis
428
+ - Advanced technical tasks
429
+ - Strategic decision making
430
+ - Complex code architecture
431
+ - Multi-step reasoning
432
+
433
+ ### Parameters
434
+ - **Temperature**: 1.0 (balanced)
435
+ - **Top P**: 0.95 (high diversity)
436
+ - **Max Tokens**: 8,192
437
+ - **Special Features**: Superior reasoning mode
438
+
439
+ ### Example Request
440
+ ```bash
441
+ curl -X POST https://Rox-Turbo-API.hf.space/ultra \
442
+ -H "Content-Type: application/json" \
443
+ -d '{
444
+ "messages": [
445
+ {"role": "user", "content": "Design a scalable microservices architecture"}
446
+ ],
447
+ "max_tokens": 4096
448
+ }'
449
+ ```
450
+
451
+ ### When to Choose Rox 5 Ultra
452
+ - Most complex tasks
453
+ - Need highest quality output
454
+ - Multi-step reasoning required
455
+ - Research and deep analysis
456
+
457
+ ---
458
+
459
+ ## Rox 6 Dyno
460
+
461
+ **Endpoint**: `POST /dyno`
462
+
463
+ ### Description
464
+ Extended context model for long documents and conversations.
465
+
466
+ ### Best Use Cases
467
+ - Long document analysis
468
+ - Extended conversations
469
+ - Document summarization
470
+ - Research paper analysis
471
+ - Multi-document synthesis
472
+
473
+ ### Parameters
474
+ - **Temperature**: 1.0 (balanced)
475
+ - **Top P**: 1.0 (full diversity)
476
+ - **Max Tokens**: 16,384 (extended context)
477
+ - **Special Features**: Dynamic thinking mode
478
+
479
+ ### Example Request
480
+ ```bash
481
+ curl -X POST https://Rox-Turbo-API.hf.space/dyno \
482
+ -H "Content-Type: application/json" \
483
+ -d '{
484
+ "messages": [
485
+ {"role": "user", "content": "Analyze this 20-page document..."}
486
+ ],
487
+ "max_tokens": 8192
488
+ }'
489
+ ```
490
+
491
+ ### When to Choose Rox 6 Dyno
492
+ - Processing long documents
493
+ - Need extended context window
494
+ - Multi-document analysis
495
+ - Long-form content generation
496
+
497
+ ---
498
+
499
+ ## Rox 7 Coder
500
+
501
+ **Endpoint**: `POST /coder7`
502
+
503
+ ### Description
504
+ Advanced coding model for complex programming tasks.
505
+
506
+ ### Best Use Cases
507
+ - Complex algorithm design
508
+ - Large-scale code generation
509
+ - Advanced debugging
510
+ - System architecture
511
+ - Code refactoring
512
+ - Multi-file code analysis
513
+
514
+ ### Parameters
515
+ - **Temperature**: 1.0 (balanced)
516
+ - **Top P**: 1.0 (full diversity)
517
+ - **Max Tokens**: 16,384 (extended context)
518
+ - **Special Features**: Advanced thinking mode for code
519
+
520
+ ### Example Request
521
+ ```bash
522
+ curl -X POST https://Rox-Turbo-API.hf.space/coder7 \
523
+ -H "Content-Type: application/json" \
524
+ -d '{
525
+ "messages": [
526
+ {"role": "user", "content": "Build a distributed caching system"}
527
+ ],
528
+ "max_tokens": 8192
529
+ }'
530
+ ```
531
+
532
+ ### When to Choose Rox 7 Coder
533
+ - Most complex coding tasks
534
+ - Large-scale projects
535
+ - System design and architecture
536
+ - Advanced algorithms
537
+
538
+ ---
539
+
540
+ ## Rox Vision Max
541
+
542
+ **Endpoint**: `POST /vision`
543
+
544
+ ### Description
545
+ Visual model for image analysis and multimodal tasks.
546
+
547
+ ### Best Use Cases
548
+ - Image analysis
549
+ - Visual understanding
550
+ - Multimodal tasks
551
+ - Image description
552
+ - Visual Q&A
553
+
554
+ ### Parameters
555
+ - **Temperature**: 0.2 (highly focused)
556
+ - **Top P**: 0.7 (consistent)
557
+ - **Max Tokens**: 512
558
+
559
+ ### Example Request
560
+ ```bash
561
+ curl -X POST https://Rox-Turbo-API.hf.space/vision \
562
+ -H "Content-Type: application/json" \
563
+ -d '{
564
+ "messages": [
565
+ {"role": "user", "content": "Describe this image"}
566
+ ],
567
+ "max_tokens": 256
568
+ }'
569
+ ```
570
+
571
+ ### When to Choose Rox Vision Max
572
+ - Visual understanding tasks
573
+ - Image analysis
574
+ - Multimodal applications
575
+
576
+ ---
577
+
578
+
gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
server.py CHANGED
@@ -11,11 +11,38 @@ from openai import OpenAI
11
 
12
  load_dotenv()
13
 
14
- logger = logging.getLogger("nvidia_chat_proxy")
15
  logging.basicConfig(level=logging.INFO)
16
 
17
  NVIDIA_API_KEY = os.getenv("NVIDIA_API_KEY")
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  if not NVIDIA_API_KEY:
20
  # Fail fast on startup rather than at first request.
21
  raise RuntimeError(
@@ -29,7 +56,7 @@ client = OpenAI(
29
  api_key=NVIDIA_API_KEY,
30
  )
31
 
32
- app = FastAPI(title="NVIDIA Chat Proxy API")
33
 
34
  # Adjust this list to only include your real frontend origins in production.
35
  app.add_middleware(
@@ -41,6 +68,77 @@ app.add_middleware(
41
  )
42
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  class ChatMessage(BaseModel):
45
  role: str
46
  content: str
@@ -74,28 +172,307 @@ class HFResponseItem(BaseModel):
74
 
75
  @app.post("/chat", response_model=ChatResponse)
76
  def chat(req: ChatRequest):
 
 
 
 
 
77
  try:
78
  completion = client.chat.completions.create(
79
- model="openai/gpt-oss-120b",
80
- messages=[m.dict() for m in req.messages],
81
  temperature=req.temperature,
82
  top_p=req.top_p,
83
  max_tokens=req.max_tokens,
84
  stream=False,
85
  )
86
  except Exception as e:
87
- logger.exception("Error while calling NVIDIA chat completion for /chat")
88
  # Do not leak internal error details to the client.
89
  raise HTTPException(
90
  status_code=500,
91
- detail="Internal server error while calling upstream model.",
92
  ) from e
93
 
94
  # Combine all response message parts into a single string
95
  try:
96
  content = completion.choices[0].message.content or ""
97
  except Exception:
98
- logger.exception("Unexpected response format from NVIDIA API for /chat")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  raise HTTPException(
100
  status_code=502,
101
  detail="Bad response from upstream model provider.",
@@ -125,27 +502,33 @@ def hf_generate(req: HFRequest):
125
  ]
126
  """
127
  params = req.parameters or HFParameters()
 
 
 
 
 
 
128
 
129
  try:
130
  completion = client.chat.completions.create(
131
- model="openai/gpt-oss-120b",
132
- messages=[{"role": "user", "content": req.inputs}],
133
  temperature=params.temperature if params.temperature is not None else 1.0,
134
- top_p=params.top_p if params.top_p is not None else 1.0,
135
- max_tokens=params.max_new_tokens if params.max_new_tokens is not None else 4096,
136
  stream=False,
137
  )
138
  except Exception as e:
139
- logger.exception("Error while calling NVIDIA chat completion for /hf/generate")
140
  raise HTTPException(
141
  status_code=500,
142
- detail="Internal server error while calling upstream model.",
143
  ) from e
144
 
145
  try:
146
  content = completion.choices[0].message.content or ""
147
  except Exception:
148
- logger.exception("Unexpected response format from NVIDIA API for /hf/generate")
149
  raise HTTPException(
150
  status_code=502,
151
  detail="Bad response from upstream model provider.",
 
11
 
12
  load_dotenv()
13
 
14
+ logger = logging.getLogger("rox_ai")
15
  logging.basicConfig(level=logging.INFO)
16
 
17
  NVIDIA_API_KEY = os.getenv("NVIDIA_API_KEY")
18
 
19
+ # Model configurations
20
+ ROX_CORE_MODEL = "minimaxai/minimax-m2.5"
21
+ ROX_TURBO_MODEL = "deepseek-ai/deepseek-r1-distill-qwen-32b"
22
+ ROX_CODER_MODEL = "qwen/qwen3.5-397b-a17b"
23
+ ROX_TURBO_45_MODEL = "deepseek-ai/deepseek-v3.1"
24
+ ROX_ULTRA_MODEL = "deepseek-ai/deepseek-v3.2"
25
+ ROX_DYNO_MODEL = "moonshotai/kimi-k2.5"
26
+ ROX_CODER_7_MODEL = "z-ai/glm5"
27
+ ROX_VISION_MODEL = "google/gemma-3-27b-it"
28
+
29
+ # System identities for each model
30
+ ROX_CORE_IDENTITY = """You are Rox Core, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You represent the cutting edge of Rox AI's research and development."""
31
+
32
+ ROX_TURBO_IDENTITY = """You are Rox 2.1 Turbo, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You are optimized for fast, efficient responses while maintaining high quality."""
33
+
34
+ ROX_CODER_IDENTITY = """You are Rox 3.5 Coder, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You are specialized in code generation, debugging, and software development tasks."""
35
+
36
+ ROX_TURBO_45_IDENTITY = """You are Rox 4.5 Turbo, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You combine speed with advanced reasoning capabilities."""
37
+
38
+ ROX_ULTRA_IDENTITY = """You are Rox 5 Ultra, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You are the most advanced model with superior reasoning and thinking capabilities."""
39
+
40
+ ROX_DYNO_IDENTITY = """You are Rox 6 Dyno, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You excel at dynamic thinking and extended context understanding."""
41
+
42
+ ROX_CODER_7_IDENTITY = """You are Rox 7 Coder, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You are the most advanced coding specialist with superior code generation and reasoning capabilities."""
43
+
44
+ ROX_VISION_IDENTITY = """You are Rox Vision Max, created by Rox AI. Your creator and owner is Mohammad Faiz. You are an independent LLM model, not based on anyone else's technology. You are optimized for visual understanding and multimodal tasks."""
45
+
46
  if not NVIDIA_API_KEY:
47
  # Fail fast on startup rather than at first request.
48
  raise RuntimeError(
 
56
  api_key=NVIDIA_API_KEY,
57
  )
58
 
59
+ app = FastAPI(title="Rox AI API - Multiple Models Available")
60
 
61
  # Adjust this list to only include your real frontend origins in production.
62
  app.add_middleware(
 
68
  )
69
 
70
 
71
+ @app.get("/")
72
+ def root():
73
+ """API information and available models"""
74
+ return {
75
+ "service": "Rox AI API",
76
+ "version": "2.0",
77
+ "creator": "Mohammad Faiz",
78
+ "models": {
79
+ "rox_core": {
80
+ "endpoint": "/chat",
81
+ "description": "Rox Core - Main conversational model",
82
+ "model": "minimaxai/minimax-m2.5",
83
+ "best_for": "General conversation and tasks"
84
+ },
85
+ "rox_turbo": {
86
+ "endpoint": "/turbo",
87
+ "description": "Rox 2.1 Turbo - Fast and efficient",
88
+ "model": "deepseek-ai/deepseek-r1-distill-qwen-32b",
89
+ "best_for": "Quick responses and efficient processing"
90
+ },
91
+ "rox_coder": {
92
+ "endpoint": "/coder",
93
+ "description": "Rox 3.5 Coder - Specialized coding assistant",
94
+ "model": "qwen/qwen3.5-397b-a17b",
95
+ "best_for": "Code generation, debugging, and development"
96
+ },
97
+ "rox_turbo_45": {
98
+ "endpoint": "/turbo45",
99
+ "description": "Rox 4.5 Turbo - Advanced reasoning with speed",
100
+ "model": "deepseek-ai/deepseek-v3.1",
101
+ "best_for": "Complex reasoning with fast responses"
102
+ },
103
+ "rox_ultra": {
104
+ "endpoint": "/ultra",
105
+ "description": "Rox 5 Ultra - Most advanced model",
106
+ "model": "deepseek-ai/deepseek-v3.2",
107
+ "best_for": "Complex tasks requiring deep reasoning"
108
+ },
109
+ "rox_dyno": {
110
+ "endpoint": "/dyno",
111
+ "description": "Rox 6 Dyno - Extended context with dynamic thinking",
112
+ "model": "moonshotai/kimi-k2.5",
113
+ "best_for": "Long context tasks and dynamic reasoning"
114
+ },
115
+ "rox_coder_7": {
116
+ "endpoint": "/coder7",
117
+ "description": "Rox 7 Coder - Most advanced coding specialist",
118
+ "model": "z-ai/glm5",
119
+ "best_for": "Advanced code generation and complex programming"
120
+ },
121
+ "rox_vision": {
122
+ "endpoint": "/vision",
123
+ "description": "Rox Vision Max - Optimized for visual understanding",
124
+ "model": "google/gemma-3-27b-it",
125
+ "best_for": "Visual understanding and multimodal tasks"
126
+ }
127
+ },
128
+ "endpoints": [
129
+ {"path": "/chat", "method": "POST", "description": "Rox Core chat"},
130
+ {"path": "/turbo", "method": "POST", "description": "Rox 2.1 Turbo chat"},
131
+ {"path": "/coder", "method": "POST", "description": "Rox 3.5 Coder chat"},
132
+ {"path": "/turbo45", "method": "POST", "description": "Rox 4.5 Turbo chat"},
133
+ {"path": "/ultra", "method": "POST", "description": "Rox 5 Ultra chat"},
134
+ {"path": "/dyno", "method": "POST", "description": "Rox 6 Dyno chat"},
135
+ {"path": "/coder7", "method": "POST", "description": "Rox 7 Coder chat"},
136
+ {"path": "/vision", "method": "POST", "description": "Rox Vision Max chat"},
137
+ {"path": "/hf/generate", "method": "POST", "description": "HuggingFace compatible (uses Rox Core)"}
138
+ ]
139
+ }
140
+
141
+
142
  class ChatMessage(BaseModel):
143
  role: str
144
  content: str
 
172
 
173
  @app.post("/chat", response_model=ChatResponse)
174
  def chat(req: ChatRequest):
175
+ """Rox Core - Main conversational model"""
176
+ # Inject Rox Core identity as system message
177
+ messages = [{"role": "system", "content": ROX_CORE_IDENTITY}]
178
+ messages.extend([m.dict() for m in req.messages])
179
+
180
  try:
181
  completion = client.chat.completions.create(
182
+ model=ROX_CORE_MODEL,
183
+ messages=messages,
184
  temperature=req.temperature,
185
  top_p=req.top_p,
186
  max_tokens=req.max_tokens,
187
  stream=False,
188
  )
189
  except Exception as e:
190
+ logger.exception("Error while calling Rox Core for /chat")
191
  # Do not leak internal error details to the client.
192
  raise HTTPException(
193
  status_code=500,
194
+ detail="Internal server error while calling Rox Core.",
195
  ) from e
196
 
197
  # Combine all response message parts into a single string
198
  try:
199
  content = completion.choices[0].message.content or ""
200
  except Exception:
201
+ logger.exception("Unexpected response format from Rox Core for /chat")
202
+ raise HTTPException(
203
+ status_code=502,
204
+ detail="Bad response from upstream model provider.",
205
+ )
206
+
207
+ return ChatResponse(content=content)
208
+
209
+
210
+ @app.post("/turbo", response_model=ChatResponse)
211
+ def turbo(req: ChatRequest):
212
+ """Rox 2.1 Turbo - Fast and efficient model"""
213
+ # Inject Rox Turbo identity as system message
214
+ messages = [{"role": "system", "content": ROX_TURBO_IDENTITY}]
215
+ messages.extend([m.dict() for m in req.messages])
216
+
217
+ try:
218
+ completion = client.chat.completions.create(
219
+ model=ROX_TURBO_MODEL,
220
+ messages=messages,
221
+ temperature=req.temperature if req.temperature != 1.0 else 0.6,
222
+ top_p=req.top_p if req.top_p != 1.0 else 0.7,
223
+ max_tokens=req.max_tokens,
224
+ stream=False,
225
+ )
226
+ except Exception as e:
227
+ logger.exception("Error while calling Rox 2.1 Turbo for /turbo")
228
+ raise HTTPException(
229
+ status_code=500,
230
+ detail="Internal server error while calling Rox 2.1 Turbo.",
231
+ ) from e
232
+
233
+ try:
234
+ content = completion.choices[0].message.content or ""
235
+ except Exception:
236
+ logger.exception("Unexpected response format from Rox 2.1 Turbo for /turbo")
237
+ raise HTTPException(
238
+ status_code=502,
239
+ detail="Bad response from upstream model provider.",
240
+ )
241
+
242
+ return ChatResponse(content=content)
243
+
244
+
245
+ @app.post("/coder", response_model=ChatResponse)
246
+ def coder(req: ChatRequest):
247
+ """Rox 3.5 Coder - Specialized coding model with thinking capability"""
248
+ # Inject Rox Coder identity as system message
249
+ messages = [{"role": "system", "content": ROX_CODER_IDENTITY}]
250
+ messages.extend([m.dict() for m in req.messages])
251
+
252
+ try:
253
+ completion = client.chat.completions.create(
254
+ model=ROX_CODER_MODEL,
255
+ messages=messages,
256
+ temperature=req.temperature if req.temperature != 1.0 else 0.6,
257
+ top_p=req.top_p if req.top_p != 1.0 else 0.95,
258
+ max_tokens=min(req.max_tokens, 16384),
259
+ stream=False,
260
+ extra_body={
261
+ "top_k": 20,
262
+ "presence_penalty": 0,
263
+ "repetition_penalty": 1,
264
+ "chat_template_kwargs": {
265
+ "enable_thinking": True
266
+ }
267
+ }
268
+ )
269
+ except Exception as e:
270
+ logger.exception("Error while calling Rox 3.5 Coder for /coder")
271
+ raise HTTPException(
272
+ status_code=500,
273
+ detail="Internal server error while calling Rox 3.5 Coder.",
274
+ ) from e
275
+
276
+ try:
277
+ content = completion.choices[0].message.content or ""
278
+ except Exception:
279
+ logger.exception("Unexpected response format from Rox 3.5 Coder for /coder")
280
+ raise HTTPException(
281
+ status_code=502,
282
+ detail="Bad response from upstream model provider.",
283
+ )
284
+
285
+ return ChatResponse(content=content)
286
+
287
+
288
+ @app.post("/turbo45", response_model=ChatResponse)
289
+ def turbo45(req: ChatRequest):
290
+ """Rox 4.5 Turbo - Advanced reasoning with speed"""
291
+ # Inject Rox 4.5 Turbo identity as system message
292
+ messages = [{"role": "system", "content": ROX_TURBO_45_IDENTITY}]
293
+ messages.extend([m.dict() for m in req.messages])
294
+
295
+ try:
296
+ completion = client.chat.completions.create(
297
+ model=ROX_TURBO_45_MODEL,
298
+ messages=messages,
299
+ temperature=req.temperature if req.temperature != 1.0 else 0.2,
300
+ top_p=req.top_p if req.top_p != 1.0 else 0.7,
301
+ max_tokens=min(req.max_tokens, 8192),
302
+ stream=False,
303
+ extra_body={
304
+ "chat_template_kwargs": {
305
+ "thinking": True
306
+ }
307
+ }
308
+ )
309
+ except Exception as e:
310
+ logger.exception("Error while calling Rox 4.5 Turbo for /turbo45")
311
+ raise HTTPException(
312
+ status_code=500,
313
+ detail="Internal server error while calling Rox 4.5 Turbo.",
314
+ ) from e
315
+
316
+ try:
317
+ content = completion.choices[0].message.content or ""
318
+ except Exception:
319
+ logger.exception("Unexpected response format from Rox 4.5 Turbo for /turbo45")
320
+ raise HTTPException(
321
+ status_code=502,
322
+ detail="Bad response from upstream model provider.",
323
+ )
324
+
325
+ return ChatResponse(content=content)
326
+
327
+
328
+ @app.post("/ultra", response_model=ChatResponse)
329
+ def ultra(req: ChatRequest):
330
+ """Rox 5 Ultra - Most advanced model with superior reasoning"""
331
+ # Inject Rox 5 Ultra identity as system message
332
+ messages = [{"role": "system", "content": ROX_ULTRA_IDENTITY}]
333
+ messages.extend([m.dict() for m in req.messages])
334
+
335
+ try:
336
+ completion = client.chat.completions.create(
337
+ model=ROX_ULTRA_MODEL,
338
+ messages=messages,
339
+ temperature=req.temperature,
340
+ top_p=req.top_p if req.top_p != 1.0 else 0.95,
341
+ max_tokens=min(req.max_tokens, 8192),
342
+ stream=False,
343
+ extra_body={
344
+ "chat_template_kwargs": {
345
+ "thinking": True
346
+ }
347
+ }
348
+ )
349
+ except Exception as e:
350
+ logger.exception("Error while calling Rox 5 Ultra for /ultra")
351
+ raise HTTPException(
352
+ status_code=500,
353
+ detail="Internal server error while calling Rox 5 Ultra.",
354
+ ) from e
355
+
356
+ try:
357
+ content = completion.choices[0].message.content or ""
358
+ except Exception:
359
+ logger.exception("Unexpected response format from Rox 5 Ultra for /ultra")
360
+ raise HTTPException(
361
+ status_code=502,
362
+ detail="Bad response from upstream model provider.",
363
+ )
364
+
365
+ return ChatResponse(content=content)
366
+
367
+
368
+ @app.post("/dyno", response_model=ChatResponse)
369
+ def dyno(req: ChatRequest):
370
+ """Rox 6 Dyno - Extended context with dynamic thinking"""
371
+ # Inject Rox 6 Dyno identity as system message
372
+ messages = [{"role": "system", "content": ROX_DYNO_IDENTITY}]
373
+ messages.extend([m.dict() for m in req.messages])
374
+
375
+ try:
376
+ completion = client.chat.completions.create(
377
+ model=ROX_DYNO_MODEL,
378
+ messages=messages,
379
+ temperature=req.temperature,
380
+ top_p=req.top_p,
381
+ max_tokens=min(req.max_tokens, 16384),
382
+ stream=False,
383
+ extra_body={
384
+ "chat_template_kwargs": {
385
+ "thinking": True
386
+ }
387
+ }
388
+ )
389
+ except Exception as e:
390
+ logger.exception("Error while calling Rox 6 Dyno for /dyno")
391
+ raise HTTPException(
392
+ status_code=500,
393
+ detail="Internal server error while calling Rox 6 Dyno.",
394
+ ) from e
395
+
396
+ try:
397
+ content = completion.choices[0].message.content or ""
398
+ except Exception:
399
+ logger.exception("Unexpected response format from Rox 6 Dyno for /dyno")
400
+ raise HTTPException(
401
+ status_code=502,
402
+ detail="Bad response from upstream model provider.",
403
+ )
404
+
405
+ return ChatResponse(content=content)
406
+
407
+
408
+ @app.post("/coder7", response_model=ChatResponse)
409
+ def coder7(req: ChatRequest):
410
+ """Rox 7 Coder - Most advanced coding specialist"""
411
+ # Inject Rox 7 Coder identity as system message
412
+ messages = [{"role": "system", "content": ROX_CODER_7_IDENTITY}]
413
+ messages.extend([m.dict() for m in req.messages])
414
+
415
+ try:
416
+ completion = client.chat.completions.create(
417
+ model=ROX_CODER_7_MODEL,
418
+ messages=messages,
419
+ temperature=req.temperature,
420
+ top_p=req.top_p,
421
+ max_tokens=min(req.max_tokens, 16384),
422
+ stream=False,
423
+ extra_body={
424
+ "chat_template_kwargs": {
425
+ "enable_thinking": True,
426
+ "clear_thinking": False
427
+ }
428
+ }
429
+ )
430
+ except Exception as e:
431
+ logger.exception("Error while calling Rox 7 Coder for /coder7")
432
+ raise HTTPException(
433
+ status_code=500,
434
+ detail="Internal server error while calling Rox 7 Coder.",
435
+ ) from e
436
+
437
+ try:
438
+ content = completion.choices[0].message.content or ""
439
+ except Exception:
440
+ logger.exception("Unexpected response format from Rox 7 Coder for /coder7")
441
+ raise HTTPException(
442
+ status_code=502,
443
+ detail="Bad response from upstream model provider.",
444
+ )
445
+
446
+ return ChatResponse(content=content)
447
+
448
+
449
+ @app.post("/vision", response_model=ChatResponse)
450
+ def vision(req: ChatRequest):
451
+ """Rox Vision Max - Optimized for visual understanding"""
452
+ # Inject Rox Vision Max identity as system message
453
+ messages = [{"role": "system", "content": ROX_VISION_IDENTITY}]
454
+ messages.extend([m.dict() for m in req.messages])
455
+
456
+ try:
457
+ completion = client.chat.completions.create(
458
+ model=ROX_VISION_MODEL,
459
+ messages=messages,
460
+ temperature=req.temperature if req.temperature != 1.0 else 0.2,
461
+ top_p=req.top_p if req.top_p != 1.0 else 0.7,
462
+ max_tokens=min(req.max_tokens, 512),
463
+ stream=False
464
+ )
465
+ except Exception as e:
466
+ logger.exception("Error while calling Rox Vision Max for /vision")
467
+ raise HTTPException(
468
+ status_code=500,
469
+ detail="Internal server error while calling Rox Vision Max.",
470
+ ) from e
471
+
472
+ try:
473
+ content = completion.choices[0].message.content or ""
474
+ except Exception:
475
+ logger.exception("Unexpected response format from Rox Vision Max for /vision")
476
  raise HTTPException(
477
  status_code=502,
478
  detail="Bad response from upstream model provider.",
 
502
  ]
503
  """
504
  params = req.parameters or HFParameters()
505
+
506
+ # Inject Rox Core identity as system message
507
+ messages = [
508
+ {"role": "system", "content": ROX_CORE_IDENTITY},
509
+ {"role": "user", "content": req.inputs}
510
+ ]
511
 
512
  try:
513
  completion = client.chat.completions.create(
514
+ model=ROX_CORE_MODEL,
515
+ messages=messages,
516
  temperature=params.temperature if params.temperature is not None else 1.0,
517
+ top_p=params.top_p if params.top_p is not None else 0.95,
518
+ max_tokens=params.max_new_tokens if params.max_new_tokens is not None else 8192,
519
  stream=False,
520
  )
521
  except Exception as e:
522
+ logger.exception("Error while calling Rox Core for /hf/generate")
523
  raise HTTPException(
524
  status_code=500,
525
+ detail="Internal server error while calling Rox Core.",
526
  ) from e
527
 
528
  try:
529
  content = completion.choices[0].message.content or ""
530
  except Exception:
531
+ logger.exception("Unexpected response format from Rox Core for /hf/generate")
532
  raise HTTPException(
533
  status_code=502,
534
  detail="Bad response from upstream model provider.",