File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ with OpenResty using
88This project implements both the classic Chat Completions API in addition to
99the modern Responses API.
1010
11+ Compatibility clients for [ Google Gemini] ( #using-with-google-gemini ) and
12+ [ OpenRouter] ( #using-with-openrouter ) are also included.
13+
1114<details >
1215<summary >AI Generated Disclaimer</summary >
1316
Original file line number Diff line number Diff line change 1+ -- Example: Using OpenRouter with chat completions
2+ -- Requires OPENROUTER_API_KEY environment variable
3+
4+ local OpenRouter = require (" openai.compat.openrouter" )
5+ local client = OpenRouter .new (os.getenv (" OPENROUTER_API_KEY" ))
6+
7+ local status , response = client :create_chat_completion ({
8+ {role = " user" , content = " Write a haiku about Lua programming" }
9+ }, {
10+ model = " xiaomi/mimo-v2-flash:free"
11+ })
12+
13+ if status == 200 then
14+ print (response .choices [1 ].message .content )
15+ else
16+ print (" Error:" , status )
17+ if response and response .error then
18+ print (response .error .message )
19+ end
20+ end
You can’t perform that action at this time.
0 commit comments