Skip to main content

Hapi advanced configuration

Hapi is suitable for long-term remote use. Stability mainly depends on three things: whether the local service is stable, whether the external access link is stable, and whether the model API configuration is stable.

Save MuskAI configuration separately​

It is recommended to create a separate service configuration for MuskAI and do not mix it with other transfer stations or official services.

  • Write the service name clearly, such as MuskAI.
  • Base URL is copied from the official website User Center - [API Key] page.
  • API Key uses a separately created Key to facilitate statistics and deactivation.
  • The model name uses the model currently available in the console.

In this way, you can directly press Key to check the usage during subsequent troubleshooting, and also avoid multiple service entrances covering each other.

Cloudflare Tunnel​

If you don't want to open the server port directly, you can use Cloudflare Tunnel to expose Hapi to your own domain name.

Basic process:

  1. Create a Tunnel in Cloudflare.
  2. Point the tunnel to Hapi's local listening address, such as http://127.0.0.1:3000.
  3. Bind a subdomain name to Tunnel.
  4. Visit the domain name to confirm that the Hapi page is available.

Safety advice:

  • Enable HTTPS.
  • Set up access protection for Hapi management portal.
  • Do not write the API Key in public pages, public repositories or browser screenshots.
  • The server only opens necessary ports.

Preferred network​

When accessing across regions, if the page loads slowly or the session is frequently disconnected, you can troubleshoot from the following directions:

  • Use Cloudflare preferred IP or a more stable access line.
  • Check server connectivity to MuskAI Base URL.
  • Avoid overlapping of local proxies and server proxies.
  • Confirm that DNS resolution is not contaminated or resolves to abnormal lines.

Run management​

For long-term use, it is recommended to keep Hapi running through systemd, pm2 or screen/tmux.

Example check command:

node -v
npm -v
ss -lntp

If the configuration is lost after Hapi is restarted, check whether its configuration directory is in the persistence path, or whether it is overwritten by containers, scripts, or cleanup tasks.

Troubleshooting order​

  1. First confirm that the Hapi local port can be accessed.
  2. Confirm that the remote domain name can be accessed.
  3. Confirm that the MuskAI API Key and Base URL are correct.
  4. Finally check the model name, balance and package permissions.

HTTP status codes can usually help you quickly locate the direction: 401/403 are mostly authentication or permission issues, 404 are mostly path or model configuration issues, and timeouts are mostly network or proxy issues.