Skip to main content

Troubleshooting

The API returns 401 Unauthorized or an authentication error​

  • Confirm that you copied the complete token string from Generate PAT.
  • Confirm that the environment variable AMSC_TOKEN contains your PAT in the same terminal where you run the command.
  • Check the format of the PAT with the command in Step 4. If it prints Token Invalid, the variable does not contain a complete PAT. A valid result does not show that the PAT has not expired.
  • Generate a new PAT on myAmSC if the PAT expired or was revoked. Then update the AMSC_TOKEN variable.

Requests are blocked by an IP restriction​

Access may be restricted by source IP address. If your network has both IPv4 and IPv6, curl and other clients may connect over IPv6, so the address the gateway sees may differ from the IPv4 address you expect.

Check which address your client uses:

curl -s https://ifconfig.me ; echo

If the result is an IPv6 address (it contains colons), the gateway sees that address. Ask for it to be allowed, or force IPv4 where your client supports it, for example curl -4. Not every client can force IPv4.

Requests time out or cannot connect from an HPC system​

Some HPC systems have no direct outbound internet access and require an HTTP proxy. If requests hang or fail to connect, set the proxy variables in the same terminal before you run the command or start the tool. Use the proxy address for your site. For example, on ALCF:

export HTTP_PROXY="http://proxy.alcf.anl.gov:3128"
export HTTPS_PROXY="http://proxy.alcf.anl.gov:3128"
export http_proxy="http://proxy.alcf.anl.gov:3128"
export https_proxy="http://proxy.alcf.anl.gov:3128"

Some tools read only the uppercase names and others only the lowercase names, so set both. Ask your site's support staff for the correct proxy address if you do not know it.

A command cannot find the PAT​

Environment variables set with export apply only to the current terminal session and its child processes. Set the variable again in the current terminal, then restart the application from that terminal.

A model request fails​

  • Call /v1/models again and confirm that the model is available to your account.
  • Check the model name for spelling.
  • If you use an exact model version, try its family alias to determine whether that version is still available.

A long request is dropped or times out​

Frontier models can take more than 120 seconds to process a request, for example with high reasoning effort or a long context. If the client receives no data during that time, the connection may be dropped before the response arrives.

Use streaming mode. The gateway then sends data as the model produces it, which keeps the connection open. Set "stream": true in the request body:

curl -N https://mag.genesis.americansciencecloud.org/v1/chat/completions \
-H "Authorization: Bearer $AMSC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"stream": true,
"messages": [{"role": "user", "content": "Hello"}]
}'
  • In the OpenAI and Anthropic SDKs, pass stream=True and read the response as it arrives. The -N option disables output buffering in curl.
  • Also raise the client's own timeout, because many clients stop waiting before 120 seconds.
  • Claude Code and Codex stream by default. If they still drop connections, lower the reasoning effort or clear the context.

Claude Code or Codex does not use MAG​

  • Start the tool from the terminal where you set its environment variables.
  • Verify the appropriate variable names using the commands in the tool's section.
  • Check that the base URL exactly matches the value shown in this guide.