12
12
13
13
* [ 中文说明] ( README.zh.md ) | English*
14
14
15
- A complete OpenAI API compatible mock server that returns predefined test data without calling real LLMs. Perfect for developing, testing, and debugging applications that use the OpenAI API .
15
+ A complete ** OpenAI, Anthropic, and Gemini API** compatible mock server that returns predefined test data without calling real LLMs. Perfect for developing, testing, and debugging applications that use these AI APIs .
16
16
17
17
## 🚀 Quick Start
18
18
@@ -205,6 +205,8 @@ curl -X POST http://localhost:3000/v1/images/generations \
205
205
## 🎯 Features
206
206
207
207
- ✅ ** Full OpenAI API Compatibility**
208
+ - ✅ ** Anthropic Claude API Support**
209
+ - ✅ ** Google Gemini API Support**
208
210
- ✅ ** Support for streaming and non-streaming chat completions**
209
211
- ✅ ** Function calling support**
210
212
- ✅ ** Image generation support**
@@ -217,24 +219,31 @@ curl -X POST http://localhost:3000/v1/images/generations \
217
219
218
220
## 📋 Supported API Endpoints
219
221
220
- ### Model Management
222
+ ### OpenAI Compatible Endpoints
221
223
- ` GET /v1/models ` - Get available model list
222
224
- ` GET /models ` - Compatible endpoint
223
-
224
- ### Chat Completions
225
225
- ` POST /v1/chat/completions ` - Create chat completion
226
226
- ` POST /chat/completions ` - Compatible endpoint
227
-
228
- ### Image Generation
229
227
- ` POST /v1/images/generations ` - Generate images
230
228
- ` POST /images/generations ` - Compatible endpoint
231
229
230
+ ### Anthropic Compatible Endpoints
231
+ - ` GET /anthropic/v1/models ` - Get Anthropic model list
232
+ - ` POST /anthropic/v1/messages ` - Create message (Claude API)
233
+
234
+ ### Gemini Compatible Endpoints
235
+ - ` GET /v1beta/models ` - Get Gemini model list
236
+ - ` POST /v1beta/models/{model}:generateContent ` - Generate content
237
+ - ` POST /v1beta/models/{model}:streamGenerateContent ` - Generate content (streaming)
238
+
232
239
### Health Check
233
240
- ` GET /health ` - Server health status
234
241
235
242
## 🤖 Available Models
236
243
237
- ### 1. mock-gpt-thinking
244
+ ### OpenAI Compatible Models
245
+
246
+ #### 1. mock-gpt-thinking
238
247
** Thinking Model** - Shows reasoning process, perfect for debugging logic
239
248
240
249
``` json
@@ -246,7 +255,7 @@ curl -X POST http://localhost:3000/v1/images/generations \
246
255
247
256
Response will include ` <thinking> ` tags showing the reasoning process.
248
257
249
- ### 2. gpt-4-mock
258
+ #### 2. gpt-4-mock
250
259
** Function Calling Model** - Supports tools and function calling
251
260
252
261
``` json
@@ -269,7 +278,7 @@ Response will include `<thinking>` tags showing the reasoning process.
269
278
}
270
279
```
271
280
272
- ### 3. mock-gpt-markdown
281
+ #### 3. mock-gpt-markdown
273
282
** Markdown Sample Model** - Outputs standard Markdown format plain text
274
283
275
284
``` json
@@ -282,7 +291,7 @@ Response will include `<thinking>` tags showing the reasoning process.
282
291
Response will be a complete Markdown document with various formatting elements, perfect for frontend UI debugging.
283
292
** Note:** This model focuses on content display and doesn't support function calling to maintain output purity.
284
293
285
- ### 4. gpt-4o-image
294
+ #### 4. gpt-4o-image
286
295
** Image Generation Model** - Specialized for image generation
287
296
288
297
``` json
@@ -297,6 +306,45 @@ Response will be a complete Markdown document with various formatting elements,
297
306
298
307
Supports various sizes and quality settings, returns high-quality simulated images.
299
308
309
+ ### Anthropic Compatible Models
310
+
311
+ #### 1. mock-claude-markdown
312
+ ** Claude Markdown Model** - Anthropic-compatible markdown generation
313
+
314
+ ``` json
315
+ {
316
+ "model" : " mock-claude-markdown" ,
317
+ "messages" : [{"role" : " user" , "content" : " Hello" }],
318
+ "max_tokens" : 1000
319
+ }
320
+ ```
321
+
322
+ ### Gemini Compatible Models
323
+
324
+ #### 1. gemini-1.5-pro
325
+ ** Advanced Multimodal Model** - Google's most advanced model
326
+
327
+ ``` json
328
+ {
329
+ "contents" : [
330
+ {
331
+ "parts" : [
332
+ {"text" : " Explain quantum computing" }
333
+ ]
334
+ }
335
+ ]
336
+ }
337
+ ```
338
+
339
+ #### 2. gemini-1.5-flash
340
+ ** Fast Response Model** - Optimized for quick responses
341
+
342
+ #### 3. gemini-pro
343
+ ** Versatile Model** - For various tasks including function calling
344
+
345
+ #### 4. gemini-pro-vision
346
+ ** Multimodal Model** - Understands both text and images
347
+
300
348
## 🛠️ Development
301
349
302
350
### Local Development
@@ -441,41 +489,40 @@ docker run -p 3000:3000 my-mock-openai-api
441
489
442
490
### Testing with curl
443
491
444
- ``` bash
445
- # Test public service
446
- curl https://mockllm.anya2a.com/health
447
- curl https://mockllm.anya2a.com/v1/models \
448
- -H " Authorization: Bearer DeepChat"
492
+ #### OpenAI API Testing
449
493
450
- # Test local service
494
+ ``` bash
495
+ # Test OpenAI health check
451
496
curl http://localhost:3000/health
497
+
498
+ # Test OpenAI models
452
499
curl http://localhost:3000/v1/models
453
500
454
- # Test thinking model
501
+ # Test OpenAI thinking model
455
502
curl -X POST http://localhost:3000/v1/chat/completions \
456
503
-H " Content-Type: application/json" \
457
504
-d ' {
458
505
"model": "mock-gpt-thinking",
459
506
"messages": [{"role": "user", "content": "Explain recursion"}]
460
507
}'
461
508
462
- # Test function calling
509
+ # Test OpenAI function calling
463
510
curl -X POST http://localhost:3000/v1/chat/completions \
464
511
-H " Content-Type: application/json" \
465
512
-d ' {
466
513
"model": "gpt-4-mock",
467
514
"messages": [{"role": "user", "content": "What time is it now?"}]
468
515
}'
469
516
470
- # Test Markdown output
517
+ # Test OpenAI markdown output
471
518
curl -X POST http://localhost:3000/v1/chat/completions \
472
519
-H " Content-Type: application/json" \
473
520
-d ' {
474
521
"model": "mock-gpt-markdown",
475
522
"messages": [{"role": "user", "content": "Any content"}]
476
523
}'
477
524
478
- # Test streaming output
525
+ # Test OpenAI streaming
479
526
curl -X POST http://localhost:3000/v1/chat/completions \
480
527
-H " Content-Type: application/json" \
481
528
-d ' {
@@ -484,7 +531,7 @@ curl -X POST http://localhost:3000/v1/chat/completions \
484
531
"stream": true
485
532
}'
486
533
487
- # Test image generation
534
+ # Test OpenAI image generation
488
535
curl -X POST http://localhost:3000/v1/images/generations \
489
536
-H " Content-Type: application/json" \
490
537
-d ' {
@@ -495,6 +542,102 @@ curl -X POST http://localhost:3000/v1/images/generations \
495
542
}'
496
543
```
497
544
545
+ #### Anthropic API Testing
546
+
547
+ ``` bash
548
+ # Test Anthropic models
549
+ curl http://localhost:3000/anthropic/v1/models
550
+
551
+ # Test Anthropic messages
552
+ curl -X POST http://localhost:3000/anthropic/v1/messages \
553
+ -H " Content-Type: application/json" \
554
+ -d ' {
555
+ "model": "mock-claude-markdown",
556
+ "messages": [{"role": "user", "content": "Hello Claude"}],
557
+ "max_tokens": 1000
558
+ }'
559
+
560
+ # Test Anthropic streaming
561
+ curl -X POST http://localhost:3000/anthropic/v1/messages \
562
+ -H " Content-Type: application/json" \
563
+ -d ' {
564
+ "model": "mock-claude-markdown",
565
+ "messages": [{"role": "user", "content": "Tell me about AI"}],
566
+ "max_tokens": 1000,
567
+ "stream": true
568
+ }'
569
+ ```
570
+
571
+ #### Gemini API Testing
572
+
573
+ ``` bash
574
+ # Test Gemini models
575
+ curl http://localhost:3000/v1beta/models
576
+
577
+ # Test Gemini content generation (matching official API format)
578
+ curl -X POST http://localhost:3000/v1beta/models/gemini-1.5-pro:generateContent \
579
+ -H " Content-Type: application/json" \
580
+ -d ' {
581
+ "contents": [
582
+ {
583
+ "parts": [
584
+ {
585
+ "text": "Explain how AI works in a few words"
586
+ }
587
+ ]
588
+ }
589
+ ],
590
+ "generationConfig": {
591
+ "thinkingConfig": {
592
+ "thinkingBudget": 0
593
+ }
594
+ }
595
+ }'
596
+
597
+ # Test Gemini streaming
598
+ curl -X POST http://localhost:3000/v1beta/models/gemini-1.5-flash:streamGenerateContent \
599
+ -H " Content-Type: application/json" \
600
+ -d ' {
601
+ "contents": [
602
+ {
603
+ "parts": [
604
+ {
605
+ "text": "Write a short story about a robot"
606
+ }
607
+ ]
608
+ }
609
+ ]
610
+ }'
611
+
612
+ # Test different Gemini model
613
+ curl -X POST http://localhost:3000/v1beta/models/gemini-pro:generateContent \
614
+ -H " Content-Type: application/json" \
615
+ -d ' {
616
+ "contents": [
617
+ {
618
+ "parts": [
619
+ {
620
+ "text": "What are the benefits of renewable energy?"
621
+ }
622
+ ]
623
+ }
624
+ ],
625
+ "generationConfig": {
626
+ "temperature": 0.7,
627
+ "maxOutputTokens": 1000
628
+ }
629
+ }'
630
+ ```
631
+
632
+ #### Public Service Testing
633
+
634
+ ``` bash
635
+ # Test public service
636
+ curl https://mockllm.anya2a.com/health
637
+ curl https://mockllm.anya2a.com/v1/models \
638
+ -H " Authorization: Bearer DeepChat"
639
+ ```
640
+
498
641
### Testing with OpenAI SDK
499
642
500
643
``` javascript
0 commit comments