gmi / README.md
bibibi12345's picture
error response handling
df13dd2
---
title: GMI to OpenAI API
emoji: ๐Ÿš€
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
---
# GMI to OpenAI API Adapter
This project provides a Flask-based adapter to convert GMI's chat API to the standard OpenAI API format.
## Authentication
This adapter uses Bearer token authentication. You must provide an `Authorization` header with a Bearer token.
The default password is `123456`. You can change it by setting the `ADAPTER_PASSWORD` environment variable.
## Environment Variables
- `ADAPTER_PASSWORD`: The password for the adapter. Defaults to `123456`.
- `HTTP_PROXY` or `HTTPS_PROXY`: If you want to use a proxy for the requests to the GMI API, you can set this environment variable.
## Local Usage
1. **Install dependencies:**
```bash
pip install -r requirements.txt
```
2. **Run the application:**
```bash
export ADAPTER_PASSWORD="your_secret_password"
gunicorn --worker-class gevent --bind 0.0.0.0:7860 app:app
```
The application will be running on `http://127.0.0.1:7860`.
### List Models
**Request:**
```bash
curl -H "Authorization: Bearer your_secret_password" http://127.0.0.1:7860/v1/models
```
### Chat Completions
**Request (non-streaming):**
```bash
curl --request POST \
--url http://127.0.0.1:7860/v1/chat/completions \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your_secret_password' \
--data '{
"model": "deepseek-ai/DeepSeek-R1-0528",
"messages": [
{
"role": "user",
"content": "hi"
}
]
}'
```
**Request (streaming):**
```bash
curl --request POST \
--url http://127.0.0.1:7860/v1/chat/completions \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your_secret_password' \
--data '{
"model": "deepseek-ai/DeepSeek-R1-0528",
"stream": true,
"messages": [
{
"role": "user",
"content": "hi"
}
]
}'
```
## Docker
You can also run this application inside a Docker container.
1. **Build the Docker image:**
```bash
docker build -t gmi-to-openai .
```
2. **Run the Docker container:**
```bash
docker run -p 7860:7860 -e ADAPTER_PASSWORD="your_secret_password" gmi-to-openai