Skip to content

Make your first iDreame chat API call

Goal

Read an API token from an environment variable, query the currently available models, and complete one non-streaming chat request.

Prerequisites

  1. Sign in to the iDreame Console and create a token.
  2. Confirm that your account is active and has an available balance.
  3. Install curl locally.

Steps

Put the token in an environment variable for the current terminal. Never place a real token in a tutorial, source repository, or browser frontend:

bash
export IDREAME_API_KEY="replace-with-your-token"

Query the model list and choose an available model ID from the response:

bash
curl https://api.idreame.ai/v1/models \
  -H "Authorization: Bearer $IDREAME_API_KEY"

Store the selected ID in another environment variable, then send the chat request:

bash
export IDREAME_MODEL_ID="replace-with-a-model-id-from-the-list"

curl https://api.idreame.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $IDREAME_API_KEY" \
  -d "{\"model\":\"$IDREAME_MODEL_ID\",\"messages\":[{\"role\":\"user\",\"content\":\"Describe what you can do in one sentence.\"}]}"

Expected result

The model-list request returns the models currently available to the token. The chat request returns JSON whose choices[0].message.content contains the response.

Troubleshooting

  • 401: verify that the token is complete and active and that the header uses Bearer.
  • model_not_found: request the model list again and use an ID from the response.
  • 429: lower the request rate and use exponential backoff as described in the API overview.
  • Other errors: consult Error codes and record the error details returned by the API.

OpenAI-compatible · Multimodal AI gateway