Docs contents

Use curl with GoiAPI

Call the API over plain HTTP with curl, in OpenAI or Anthropic format: copy a ready-made request, add your API key and model name, then read the JSON reply.

Ask AI and more
View as Markdown

Step 1: Before you start

  • An API key: sign up, top up your balance, then create a key in the dashboard. Put your key where <API_KEY> appears below.
  • The name of the model you want to use, from Models. The examples below use claude-haiku-5-5.

Step 2: Set up curl

For developers: send a test call from the command line, no SDK needed.

OpenAI format

Terminal
curl https://api.goiapi.com/v1/chat/completions \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-haiku-5-5", "messages": [{"role": "user", "content": "Hello"}]}'

Anthropic format

Terminal
curl https://api.goiapi.com/v1/messages \
  -H "x-api-key: <API_KEY>" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-haiku-5-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

Step 3: Send a test message

Send a short message (for example "Hello") from curl. The Request history page in the dashboard shows the request as soon as it happens, with token counts and cost.

If something fails, see Error codes: 401 means the key is wrong or missing, 402 means your balance is too low, 404 means the model name is wrong.