You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 12, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: documents/README_OPENROUTER.md
+48-7Lines changed: 48 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,20 +145,20 @@ For the Gemini API, due to issues like rate limiting and blocking, sync objects
145
145
146
146
The `OpenRouter` class is designed to manage API interactions with OpenRouter for creating chat completions using AI models asynchronously. This class utilizes `aiohttp` for asynchronous network calls.
147
147
148
+
<br>
148
149
149
-
150
-
## Class Usage
150
+
## Usage
151
151
152
152
### Initialization
153
153
154
154
Initialize an instance of `OpenRouter` with your model identifier and API key:
155
155
156
156
```python
157
-
fromopen_router_asyncimportOpenRouter
157
+
fromgeminiimportAsyncOpenRouter
158
158
159
159
api_key ='your_api_key_here'
160
160
model ='google/gemma-7b-it:free'
161
-
router =OpenRouter(model, api_key)
161
+
router =AsyncOpenRouter(model, api_key)
162
162
```
163
163
164
164
### Single Chat Completion
@@ -169,13 +169,19 @@ To generate a single chat completion asynchronously:
169
169
import asyncio
170
170
171
171
asyncdefmain():
172
-
completion =await router.create_chat_completion("Hello, how can I help you today?")
172
+
completion =await router.create_chat_completion("Give me infomation of Seoul, Korea.")
173
173
print(completion)
174
174
175
175
if__name__=="__main__":
176
176
asyncio.run(main())
177
177
```
178
178
179
+
```python
180
+
from gemini import AsyncOpenRouter
181
+
182
+
payload =await GemmaClient.create_chat_completion("Give me infomation of Seoul, Korea.")
0 commit comments