2024-12-12 13:45:11 +08:00
# GLM AI Free Service
2024-12-12 12:51:19 +08:00
[![ ](https://img.shields.io/github/license/llm-red-team/glm-free-api.svg )](LICENSE)
![](https://img.shields.io/github/stars/llm-red-team/glm-free-api.svg)
![](https://img.shields.io/github/forks/llm-red-team/glm-free-api.svg)
![](https://img.shields.io/docker/pulls/vinlic/glm-free-api.svg)
2024-12-12 13:45:11 +08:00
Supports high-speed streaming output, multi-turn dialogues, internet search, long document reading, image analysis, zero-configuration deployment, multi-token support, and automatic session trace cleanup.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Fully compatible with the ChatGPT interface.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Also, the following free APIs are available for your attention:
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Moonshot AI (Kimi.ai) API to API [kimi-free-api ](https://github.com/LLM-Red-Team/kimi-free-api/tree/master )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
StepFun (StepChat) API to API [step-free-api ](https://github.com/LLM-Red-Team/step-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Ali Tongyi (Qwen) API to API [qwen-free-api ](https://github.com/LLM-Red-Team/qwen-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
ZhipuAI (ChatGLM) API to API [glm-free-api ](https://github.com/LLM-Red-Team/glm-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
ByteDance (Doubao) API to API [doubao-free-api ](https://github.com/LLM-Red-Team/doubao-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Meta Sota (metaso) API to API [metaso-free-api ](https://github.com/LLM-Red-Team/metaso-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Iflytek Spark (Spark) API to API [spark-free-api ](https://github.com/LLM-Red-Team/spark-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
MiniMax( Hailuo) API to API [hailuo-free-api ](https://github.com/LLM-Red-Team/hailuo-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
DeepSeek( DeepSeek) API to API [deepseek-free-api ](https://github.com/LLM-Red-Team/deepseek-free-api )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Lingxin Intelligence (Emohaa) API to API [emohaa-free-api ](https://github.com/LLM-Red-Team/emohaa-free-api ) (OUT OF ORDER)
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
## Table of Contents
* [Announcement ](#Announcement )
* [Online Experience ](#Online-Experience )
* [Effect Examples ](#Effect-Examples )
* [Access Preparation ](#Access-Preparation )
* [Agent Access ](#Agent-Access )
* [Multiple Account Access ](#Multiple-Account-Access )
* [Docker Deployment ](#Docker-Deployment )
* [Docker-compose Deployment ](#Docker-compose-Deployment )
* [Render Deployment ](#Render-Deployment )
* [Vercel Deployment ](#Vercel-Deployment )
* [Native Deployment ](#Native-Deployment )
* [Recommended Clients ](#Recommended-Clients )
* [Interface List ](#Interface-List )
* [Conversation Completion ](#Conversation-Completion )
* [Video Generation ](#Video-Generation )
* [AI Drawing ](#AI-Drawing )
* [Document Interpretation ](#Document-Interpretation )
* [Image Analysis ](#Image-Analysis )
* [Refresh_token Survival Detection ](#Refresh_token-Survival-Detection )
* [Notification ](#Notification )
* [Nginx Anti-generation Optimization ](#Nginx-Anti-generation-Optimization )
* [Token Statistics ](#Token-Statistics )
2024-12-12 12:51:19 +08:00
* [Star History ](#star-history )
2024-12-12 13:45:11 +08:00
## Announcement
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**This API is unstable. So we highly recommend you go to the [Zhipu ](https://open.bigmodel.cn/ ) use the offical API, avoiding banned.**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**This organization and individuals do not accept any financial donations and transactions. This project is purely for research, communication, and learning purposes!**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**For personal use only, it is forbidden to provide services or commercial use externally to avoid causing service pressure on the official, otherwise, bear the risk yourself!**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**For personal use only, it is forbidden to provide services or commercial use externally to avoid causing service pressure on the official, otherwise, bear the risk yourself!**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**For personal use only, it is forbidden to provide services or commercial use externally to avoid causing service pressure on the official, otherwise, bear the risk yourself!**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
## Online Experience
This link is only for temporary testing of functions and cannot be used for a long time. For long-term use, please deploy by yourself.
2024-12-12 12:51:19 +08:00
https://udify.app/chat/Pe89TtaX3rKXM8NS
2024-12-12 13:45:11 +08:00
## Effect Examples
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Identity Verification
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![Identity Verification ](./doc/example-1.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### AI-Agent
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Agent link: [Comments Generator](https://chatglm.cn/main/gdetail/65c046a531d3fcb034918abe)
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![AI-Agent ](./doc/example-9.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Combined with Dify workflow
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Experience link: https://udify.app/chat/m46YgeVLNzFh4zRs
2024-12-12 12:51:19 +08:00
< img width = "390" alt = "image" src = "https://github.com/LLM-Red-Team/glm-free-api/assets/20235341/4773b9f6-b1ca-460c-b3a7-c56bdb1f0659" >
2024-12-12 13:45:11 +08:00
### Multi-turn Dialogue
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![Multi-turn Dialogue ](./doc/example-6.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Video Generation
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
[View ](https://sfile.chatglm.cn/testpath/video/c1f59468-32fa-58c3-bd9d-ab4230cfe3ca_0.mp4 )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### AI Drawing
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![AI Drawing ](./doc/example-10.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Internet Search
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![Internet Search ](./doc/example-2.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Long Document Reading
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![Long Document Reading ](./doc/example-5.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Using Code
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![Using Code ](./doc/example-12.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Image Analysis
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
![Image Analysis ](./doc/example-3.png )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
## Access Preparation
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Obtain `refresh_token` from [Zhipu ](https://chatglm.cn/ )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Enter Zhipu Qingyan and start a random conversation, then press F12 to open the developer tools. Find the value of `tongyi_sso_ticket` in Application > Cookies, which will be used as the Bearer Token value for Authorization: `Authorization: Bearer TOKEN`
2024-12-12 12:51:19 +08:00
![example0 ](./doc/example-0.png )
2024-12-12 13:45:11 +08:00
### Agent Access
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Open a window of Agent Chat, the ID in the url is the ID of the Agent, which is the parameter of `model` .
2024-12-12 12:51:19 +08:00
![example11 ](./doc/example-11.png )
2024-12-12 13:45:11 +08:00
### Multiple Account Access
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
You can provide multiple account chatglm_refresh_tokens and use `,` to join them:
2024-12-12 12:51:19 +08:00
`Authorization: Bearer TOKEN1,TOKEN2,TOKEN3`
2024-12-12 13:45:11 +08:00
The service will pick one each time a request is made.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
## Docker Deployment
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Please prepare a server with a public IP and open port 8000.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Pull the image and start the service
2024-12-12 12:51:19 +08:00
```shell
2024-12-12 13:45:11 +08:00
docker run -it -d --init --name step-free-api -p 8000:8000 -e TZ=Asia/Shanghai vinlic/step-free-api:latest
2024-12-12 12:51:19 +08:00
```
2024-12-12 13:45:11 +08:00
check real-time service logs
2024-12-12 12:51:19 +08:00
```shell
docker logs -f glm-free-api
```
2024-12-12 13:45:11 +08:00
Restart service
2024-12-12 12:51:19 +08:00
```shell
docker restart glm-free-api
```
2024-12-12 13:45:11 +08:00
Shut down service
2024-12-12 12:51:19 +08:00
```shell
docker stop glm-free-api
```
2024-12-12 13:45:11 +08:00
### Docker-compose Deployment
2024-12-12 12:51:19 +08:00
```yaml
version: '3'
services:
glm-free-api:
container_name: glm-free-api
image: vinlic/glm-free-api:latest
restart: always
ports:
- "8000:8000"
environment:
- TZ=Asia/Shanghai
```
2024-12-12 13:45:11 +08:00
### Render Deployment
**Attention: Some deployment regions may not be able to connect to Kimi. If container logs show request timeouts or connection failures (Singapore has been tested and found unavailable), please switch to another deployment region!**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**Attention: Container instances for free accounts will automatically stop after a period of inactivity, which may result in a 50-second or longer delay during the next request. It is recommended to check [Render Container Keepalive ](https://github.com/LLM-Red-Team/free-api-hub/#Render%E5%AE%B9%E5%99%A8%E4%BF%9D%E6%B4%BB )**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
1. Fork this project to your GitHub account.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
2. Visit [Render ](https://dashboard.render.com/ ) and log in with your GitHub account.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
3. Build your Web Service (`New+` -> `Build and deploy from a Git repository` -> `Connect your forked project` -> `Select deployment region` -> `Choose instance type as Free` -> `Create Web Service` ).
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
4. After the build is complete, copy the assigned domain and append the URL to access it.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Vercel Deployment
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**Note: Vercel free accounts have a request response timeout of 10 seconds, but interface responses are usually longer, which may result in a 504 timeout error from Vercel!**
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Please ensure that Node.js environment is installed first.
2024-12-12 12:51:19 +08:00
```shell
npm i -g vercel --registry http://registry.npmmirror.com
vercel login
git clone https://github.com/LLM-Red-Team/glm-free-api
cd glm-free-api
vercel --prod
```
2024-12-12 13:45:11 +08:00
## Native Deployment
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Please prepare a server with a public IP and open port 8000.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Please install the Node.js environment and configure the environment variables first, and confirm that the node command is available.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Install dependencies
2024-12-12 12:51:19 +08:00
```shell
npm i
```
2024-12-12 13:45:11 +08:00
Install PM2 for process guarding
2024-12-12 12:51:19 +08:00
```shell
npm i -g pm2
```
2024-12-12 13:45:11 +08:00
Compile and build. When you see the dist directory, the build is complete.
2024-12-12 12:51:19 +08:00
```shell
npm run build
```
2024-12-12 13:45:11 +08:00
Start service
2024-12-12 12:51:19 +08:00
```shell
pm2 start dist/index.js --name "glm-free-api"
```
2024-12-12 13:45:11 +08:00
View real-time service logs
2024-12-12 12:51:19 +08:00
```shell
pm2 logs glm-free-api
```
2024-12-12 13:45:11 +08:00
Restart service
2024-12-12 12:51:19 +08:00
```shell
pm2 reload glm-free-api
```
2024-12-12 13:45:11 +08:00
Shut down service
2024-12-12 12:51:19 +08:00
```shell
pm2 stop glm-free-api
```
2024-12-12 13:45:11 +08:00
## Recommended Clients
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Using the following second-developed clients for free-api series projects is faster and easier, and supports document/image uploads!
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
[Clivia ](https://github.com/Yanyutin753/lobe-chat )'s modified LobeChat [https://github.com/Yanyutin753/lobe-chat ](https://github.com/Yanyutin753/lobe-chat )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
[Time@ ](https://github.com/SuYxh )'s modified ChatGPT Web [https://github.com/SuYxh/chatgpt-web-sea ](https://github.com/SuYxh/chatgpt-web-sea )
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
## interface List
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Currently, the `/v1/chat/completions` interface compatible with openai is supported. You can use the client access interface compatible with openai or other clients, or use online services such as [dify ](https://dify.ai/ ) Access and use.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Conversation Completion
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Conversation completion interface, compatible with openai's [chat-completions-api ](https://platform.openai.com/docs/guides/text-generation/chat-completions-api ).
2024-12-12 12:51:19 +08:00
**POST /v1/chat/completions**
2024-12-12 13:45:11 +08:00
The header needs to set the Authorization header:
2024-12-12 12:51:19 +08:00
```
Authorization: Bearer [refresh_token]
```
2024-12-12 13:45:11 +08:00
Request data:
2024-12-12 12:51:19 +08:00
```json
{
2024-12-12 13:45:11 +08:00
// Except using the Agent to fill the ID, fill in the model name as you like.
2024-12-12 12:51:19 +08:00
"model": "glm4",
2024-12-12 13:45:11 +08:00
// Currently, multi-round conversations are realized based on message merging, which in some scenarios may lead to capacity degradation and is limited by the maximum number of tokens in a single round.
// If you want a native multi-round dialog experience, you can pass in the ids obtained from the last round of messages to pick up the context
2024-12-12 12:51:19 +08:00
// "conversation_id": "65f6c28546bae1f0fbb532de",
"messages": [
{
"role": "user",
2024-12-12 13:45:11 +08:00
"content": "Who RU? "
2024-12-12 12:51:19 +08:00
}
],
2024-12-12 13:45:11 +08:00
// If using SSE stream, please set it to true, the default is false
2024-12-12 12:51:19 +08:00
"stream": false
}
```
2024-12-12 13:45:11 +08:00
Response data:
2024-12-12 12:51:19 +08:00
```json
{
"id": "65f6c28546bae1f0fbb532de",
"model": "glm4",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
2024-12-12 13:45:11 +08:00
"content": "My name is Zhipu Qingyan."
2024-12-12 12:51:19 +08:00
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 2
},
"created": 1710152062
}
```
2024-12-12 13:45:11 +08:00
### Video Generation
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Video API
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
**If you're not VIP, you will wait in line for a long time.**
2024-12-12 12:51:19 +08:00
**POST /v1/videos/generations**
2024-12-12 13:45:11 +08:00
The header needs to set the Authorization header:
2024-12-12 12:51:19 +08:00
```
Authorization: Bearer [refresh_token]
```
2024-12-12 13:45:11 +08:00
Request data:
2024-12-12 12:51:19 +08:00
```json
{
// 模型名称
// cogvideox: 默认官方视频模型
// cogvideox-pro: 先生成图像再作为参考图像生成视频, 作为视频首帧引导视频效果, 但耗时更长
"model": "cogvideox",
// 视频生成提示词
"prompt": "一只可爱的猫走在花丛中",
// 支持使用图像URL或者BASE64_URL作为视频首帧参考图像( 如果使用cogvideox-pro则会忽略此参数)
// "image_url": "https://sfile.chatglm.cn/testpath/b5341945-3839-522c-b4ab-a6268cb131d5_0.png",
// 支持设置视频风格: 卡通3D/黑白老照片/油画/电影感
// "video_style": "油画",
// 支持设置情感氛围:温馨和谐/生动活泼/紧张刺激/凄凉寂寞
// "emotional_atmosphere": "生动活泼",
// 支持设置运镜方式:水平/垂直/推近/拉远
// "mirror_mode": "水平"
}
```
2024-12-12 13:45:11 +08:00
Response data:
2024-12-12 12:51:19 +08:00
```json
{
"created": 1722103836,
"data": [
{
// 对话ID, 目前没啥用
"conversation_id": "66a537ec0603e53bccb8900a",
// 封面URL
"cover_url": "https://sfile.chatglm.cn/testpath/video_cover/c1f59468-32fa-58c3-bd9d-ab4230cfe3ca_cover_0.png",
// 视频URL
"video_url": "https://sfile.chatglm.cn/testpath/video/c1f59468-32fa-58c3-bd9d-ab4230cfe3ca_0.mp4",
// 视频时长
"video_duration": "6s",
// 视频分辨率
"resolution": "1440 × 960"
}
]
}
```
2024-12-12 13:45:11 +08:00
### AI Drawing
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
This format is compatible with the [gpt-4-vision-preview ](https://platform.openai.com/docs/guides/vision ) API format.
2024-12-12 12:51:19 +08:00
**POST /v1/images/generations**
2024-12-12 13:45:11 +08:00
The header needs to set the Authorization header:
2024-12-12 12:51:19 +08:00
```
Authorization: Bearer [refresh_token]
```
2024-12-12 13:45:11 +08:00
Request data:
2024-12-12 12:51:19 +08:00
```json
{
// 如果使用智能体请填写智能体ID到此处, 否则可以乱填
"model": "cogview-3",
2024-12-12 13:45:11 +08:00
"prompt": "A cute cat"
2024-12-12 12:51:19 +08:00
}
```
2024-12-12 13:45:11 +08:00
Response data:
2024-12-12 12:51:19 +08:00
```json
{
"created": 1711507449,
"data": [
{
"url": "https://sfile.chatglm.cn/testpath/5e56234b-34ae-593c-ba4e-3f7ba77b5768_0.png"
}
]
}
```
2024-12-12 13:45:11 +08:00
### Document Interpretation
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Provide an accessible file URL or BASE64_URL to parse.
2024-12-12 12:51:19 +08:00
**POST /v1/chat/completions**
2024-12-12 13:45:11 +08:00
The header needs to set the Authorization header:
2024-12-12 12:51:19 +08:00
```
Authorization: Bearer [refresh_token]
```
2024-12-12 13:45:11 +08:00
Request data:
2024-12-12 12:51:19 +08:00
```json
{
// 如果使用智能体请填写智能体ID到此处, 否则可以乱填
"model": "glm4",
"messages": [
{
"role": "user",
"content": [
{
"type": "file",
"file_url": {
"url": "https://mj101-1317487292.cos.ap-shanghai.myqcloud.com/ai/test.pdf"
}
},
{
"type": "text",
"text": "文档里说了什么?"
}
]
}
],
// 如果使用SSE流请设置为true, 默认false
"stream": false
}
```
2024-12-12 13:45:11 +08:00
Response data:
2024-12-12 12:51:19 +08:00
```json
{
"id": "cnmuo7mcp7f9hjcmihn0",
"model": "glm4",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "根据文档内容,我总结如下:\n\n这是一份关于希腊罗马时期的魔法咒语和仪式的文本, 包含几个魔法仪式: \n\n1. 一个涉及面包、仪式场所和特定咒语的仪式,用于使某人爱上你。\n\n2. 一个针对女神赫卡忒的召唤仪式,用来折磨某人直到她自愿来到你身边。\n\n3. 一个通过念诵爱神阿芙罗狄蒂的秘密名字,连续七天进行仪式,来赢得一个美丽女子的心。\n\n4. 一个通过燃烧没药并念诵咒语,让一个女子对你产生强烈欲望的仪式。\n\n这些仪式都带有魔法和迷信色彩, 使用各种咒语和象征性行为来影响人的感情和意愿。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 2
},
"created": 100920
}
```
2024-12-12 13:45:11 +08:00
### Image Analysis
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Provide an accessible image URL or BASE64_URL to parse.
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
This format is compatible with the [gpt-4-vision-preview ](https://platform.openai.com/docs/guides/vision ) API format. You can also use this format to transmit documents for parsing.
2024-12-12 12:51:19 +08:00
**POST /v1/chat/completions**
2024-12-12 13:45:11 +08:00
The header needs to set the Authorization header:
2024-12-12 12:51:19 +08:00
```
Authorization: Bearer [refresh_token]
```
2024-12-12 13:45:11 +08:00
Request data:
2024-12-12 12:51:19 +08:00
```json
{
"model": "65c046a531d3fcb034918abe",
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "http://1255881664.vod2.myqcloud.com/6a0cd388vodbj1255881664/7b97ce1d3270835009240537095/uSfDwh6ZpB0A.png"
}
},
{
"type": "text",
"text": "图像描述了什么?"
}
]
}
],
"stream": false
}
```
2024-12-12 13:45:11 +08:00
Response data:
2024-12-12 12:51:19 +08:00
```json
{
"id": "65f6c28546bae1f0fbb532de",
"model": "glm",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "图片中展示的是一个蓝色背景下的logo, 具体地, 左边是一个由多个蓝色的圆点组成的圆形图案, 右边是“智谱·AI”四个字, 字体颜色为蓝色。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 2
},
"created": 1710670469
}
```
2024-12-12 13:45:11 +08:00
### Refresh_token Survival Detection
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Check whether refresh_token is alive. If live is not true, otherwise it is false. Please do not call this interface frequently (less than 10 minutes).
2024-12-12 12:51:19 +08:00
**POST /token/check**
2024-12-12 13:45:11 +08:00
Request data:
2024-12-12 12:51:19 +08:00
```json
{
"token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9..."
}
```
2024-12-12 13:45:11 +08:00
Response data:
2024-12-12 12:51:19 +08:00
```json
{
"live": true
}
```
2024-12-12 13:45:11 +08:00
## Notification
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
### Nginx Anti-generation Optimization
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
If you are using Nginx reverse proxy `glm-free-api` , please add the following configuration items to optimize the output effect of the stream and optimize the experience.
2024-12-12 12:51:19 +08:00
```nginx
2024-12-12 13:45:11 +08:00
# Turn off proxy buffering. When set to off, Nginx will immediately send client requests to the backend server and immediately send responses received from the backend server back to the client.
2024-12-12 12:51:19 +08:00
proxy_buffering off;
2024-12-12 13:45:11 +08:00
# Enable chunked transfer encoding. Chunked transfer encoding allows servers to send data in chunks for dynamically generated content without knowing the size of the content in advance.
2024-12-12 12:51:19 +08:00
chunked_transfer_encoding on;
2024-12-12 13:45:11 +08:00
# Turn on TCP_NOPUSH, which tells Nginx to send as much data as possible before sending the packet to the client. This is usually used in conjunction with sendfile to improve network efficiency.
2024-12-12 12:51:19 +08:00
tcp_nopush on;
2024-12-12 13:45:11 +08:00
# Turn on TCP_NODELAY, which tells Nginx not to delay sending data and to send small data packets immediately. In some cases, this can reduce network latency.
2024-12-12 12:51:19 +08:00
tcp_nodelay on;
2024-12-12 13:45:11 +08:00
#Set the timeout to keep the connection, here it is set to 120 seconds. If there is no further communication between client and server during this time, the connection will be closed.
2024-12-12 12:51:19 +08:00
keepalive_timeout 120;
```
2024-12-12 13:45:11 +08:00
### Token Statistics
2024-12-12 12:51:19 +08:00
2024-12-12 13:45:11 +08:00
Since the inference side is not in glm-free-api, the token cannot be counted and will be returned as a fixed number!!!!!
2024-12-12 12:51:19 +08:00
## Star History
[![Star History Chart ](https://api.star-history.com/svg?repos=LLM-Red-Team/glm-free-api&type=Date )](https://star-history.com/#LLM-Red-Team/glm-free-api& Date)