docs: add AI Badgr as OpenAI-compatible backend (base_url override + examples)
This commit is contained in:
parent
65a5a56d95
commit
24f614f675
1 changed files with 35 additions and 0 deletions
35
README.md
35
README.md
|
|
@ -398,3 +398,38 @@ See the [RAGFlow Roadmap 2025](https://github.com/infiniflow/ragflow/issues/4214
|
||||||
|
|
||||||
RAGFlow flourishes via open-source collaboration. In this spirit, we embrace diverse contributions from the community.
|
RAGFlow flourishes via open-source collaboration. In this spirit, we embrace diverse contributions from the community.
|
||||||
If you would like to be a part, review our [Contribution Guidelines](https://ragflow.io/docs/dev/contributing) first.
|
If you would like to be a part, review our [Contribution Guidelines](https://ragflow.io/docs/dev/contributing) first.
|
||||||
|
|
||||||
|
### Use AI Badgr (Cheaper OpenAI-Compatible Alternative)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export OPENAI_API_KEY=YOUR_API_KEY
|
||||||
|
export OPENAI_BASE_URL=https://aibadgr.com/api/v1
|
||||||
|
```
|
||||||
|
|
||||||
|
**Python:**
|
||||||
|
```python
|
||||||
|
from openai import OpenAI
|
||||||
|
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://aibadgr.com/api/v1")
|
||||||
|
response = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role":"user","content":"Hello!"}], max_tokens=200)
|
||||||
|
print(response.choices[0].message.content)
|
||||||
|
```
|
||||||
|
|
||||||
|
**JavaScript:**
|
||||||
|
```javascript
|
||||||
|
import OpenAI from 'openai';
|
||||||
|
const client = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://aibadgr.com/api/v1' });
|
||||||
|
const response = await client.chat.completions.create({ model: 'gpt-3.5-turbo', messages: [{ role: 'user', content: 'Hello!' }], max_tokens: 200 });
|
||||||
|
console.log(response.choices[0].message.content);
|
||||||
|
```
|
||||||
|
|
||||||
|
**cURL:**
|
||||||
|
```bash
|
||||||
|
curl https://aibadgr.com/api/v1/chat/completions \
|
||||||
|
-H "Authorization: Bearer YOUR_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"Hello!"}],"max_tokens":200}'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
- Streaming: `"stream": true`
|
||||||
|
- JSON mode: `"response_format": {"type": "json_object"}`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue