A reverse proxy server that adapts Grok Chat to comply with the OpenAI API format.
- OpenAI API compatible interface to Grok AI
- Support for both regular mode and "think" mode
- Support (partially) for the DeepSearch and DeeperSearch mode
- File upload support for large prompts
- Multiple browser session management for concurrent requests
- Optional API key authentication
- Streaming responses
You need Chrome installed on your system. The proxy uses the Chrome DevTools Protocol to communicate with the browser.
- Go to Github Actions and download the latest build file.
- Unzip the file.
- Make the file executable (if you are on Linux, Mac or Unix-like OS):
chmod +x app-linux-amd64
Assuming the executable is named app-windows-amd64.exe
, go to the directory where the file is located and run:
./app-windows-amd64.exe [options]
Here available options are:
-c
: Use cookies to log in (See Use Cookies)-p
: Use private mode (grok chat will not save your conversations)-h
: Use headless mode (browser will not be visible)-i <api-key>
: Set API key for authentication-n <number>
: Set the number of sessions you want to use and log in manually (See Manual Login)-port <port>
: Set the server port (default: 9867)
I suggest that you use normal mode for the first time to check if there's cloudflare protection and pass it manually. If you are not coming into any issues, you can use the headless mode.
If you call
./app-windows-amd64.exe -c -n <number>
, it will refer to thecookies
file and ignore the-n
option.
By default, just run the executable without any options for the first time,
and it will open a browser window for you to log in.
After logging in, the cookies will be saved to userdata
folder automatically.
To get the cookies:
- Go to Grok Chat
- Press F12 to open the developer tools and switch to the "Network" tab
- Refresh the page and look for a request named
grok.com
- Click on it and copy the cookies from the "Request Headers" section
- Now, create a file named
cookies
in the same directory as the executable - Paste the cookies into the file, one line for one account
- Save the file
./app-windows-amd64.exe -c
This will use the cookies from the cookies
file to log in automatically and the number of sessions will be the same as the number of lines in the cookies
file.
Not sure if manual login can pass cloudflare protection, but it should work for trusted IPs. If this is not working for you, please try use cookies.
If you don't want to use cookies, you can log in manually, and the browser will save the cookies for you.
To do this, you need to use -n <number>
option to set the number of sessions you want to use.
For example, if you want to use 2 sessions, run the following command:
./app-windows-amd64.exe -n 2
Then, there will be 2 browser windows opened, and you need to log in to each of them. After logging in, the cookies will be saved to userdata
folder automatically.
Afterwards, you can start the proxy without the -n
or -c
option, and it will use the saved user data.
- Need chrome
- Only streaming mode is supported
- Only text responses are supported (no image generation)
- Large prompts may be slower as they require file uploads
- Not very skilled at goroutines, so file an issue if you find any bugs and willing to help