Domestic has not been able to connect directly to the OPENAI API, recently xai's api also does not support direct access to the domestic, but you can continue to use through the vercel proxy, the code is as follows:
First create a warehouse (it is recommended to create a new private warehouse), create a new file name: vercel.json
Edit to save:
{ "routes": [ { "src":"/", "dest": "/index.html" }, { "src":"/gemini/v1/(. *)", { "src": "/gemini/v1/(. "dest": "https://generativelanguage.googleapis.com/v1/\" }, { "src": "/gemini/v1/(. { "src":"/gemini/v1beta/(. *)", { "src": "/gemini/v1beta/(. "dest": "https://generativelanguage.googleapis.com/v1beta/\" }, { "src": "/gemini/v1beta/(. { "src":"/openai/v1/(. *)", { "src": "/openai/v1/(. "dest": "https://api.openai.com/v1/\" }, { "src": "/openai/v1/(. { "src":"/groq/openai/v1/(. *)", { "src": "/groq/openai/v1/(. "dest": "https://api.groq.com/openai/v1/\" }, { "src": "/groq/openai/v1/(. { "src":"/claude/v1/(. *)", { "src": "/claude/v1/(. "dest": "https://api.anthropic.com/v1/\" }, { "src":"/cohere/v1/(. *)", { "src": "/cohere/v1/(. "dest": "https://api.cohere.ai/v1/\" }, { "src":"/xai/v1/(. *)", { "src": "/xai/v1/(. "dest": "https://api.x.ai/v1/\" } ], "regions": [ "src": "/xai/v1/(. "regions": [ "hnd1" ] }
Then create a new index.html to be used on the front page to display an api description, edit:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>API Access Documentation</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; padding: 20px; } .container { max-width: 800px; margin: auto; background-color: #fff; border-radius: 12px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); padding: 20px; margin-top: 20px; } h1 { text-align: center; color: #333; } p { color: #666; line-height: 1.6; } .api-info { background-color: #e9ecef; border-radius: 8px; padding: 15px; margin-top: 20px; } .api-url { font-family: 'Courier New', Courier, monospace; background-color: #d1ecf1; border-radius: 8px; padding: 10px; margin-top: 10px; } .api-example { background-color: #e9ecef; border-radius: 8px; padding: 15px; margin-top: 20px; } .code-block { background-color: #f1f8ff; border-radius: 8px; padding: 10px; margin-top: 10px; overflow-x: auto; } button { background-color: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; margin-top: 10px; } button:hover { background-color: #0056b3; } } #articlesummary { box-shadow: 0 4px 8px rgba(0,0,0,0,0); } box-shadow: 0 4px 8px rgba(0,0,0,0,0.1); } padding: 16px; margin-top: 16px; margin-top: 16px; margin-top: 16px margin-top: 16px; background-color: # background-color: #fff; } #summarycontent { margin-top: 10px; } } </style> </head> <body> <div class="container"> <h1>api access<br> API Help</h1> <div class="api-info"> <h2>API Access Support</h2> <p>openai</p> <p>gemini</p> <p>groq</p> <p>claude</p> <p>cohere</p> <p>xai</p> </div> <div class="api-info"> <h2>API Endpoint</h2> <div class="code-block"> <pre>host/theapi</pre> <pre>EXP: https://url/xai</pre> </div> </div> </div> </body> </html>
Then visit vercel.com, import this repository, no need any configuration, direct deployment can be deployed, after the deployment is complete bind your own domain name can be put in one api to play:
For example, if it is xai, the proxy address is written: https://url/xai