These examples use the OpenAI Chat Completions format. The model endpoint’s authentication requirement is verified. Authenticated discovery, chat, SDK compatibility, and streaming still require validation before publication.
1. Configure your API key
Follow account and API keys and setLLM_SG_API_KEY in the terminal or application environment where you will run the examples.
2. Choose a model
Request the available models:id from the data array. Confirm the actual response format and preserve the complete model ID.
On macOS or Linux:
YOUR_MODEL_ID with an ID provided by llm.sg. Model aliases from another service may not work here.
3. Send a request
Choose one of the following approaches. All examples readLLM_SG_API_KEY; the SDK examples also read LLM_SG_MODEL.
- cURL
- Python
- JavaScript
Run this command in Bash or Zsh. Replace
YOUR_MODEL_ID in the JSON body with the model you selected.Read the result
For a compatible text response, read the answer fromchoices[0].message.content. If the response includes usage, use it to inspect token consumption. Token counts are separate from the final billed amount.
If a request fails, record the HTTP status, error message, and request ID, then follow troubleshooting.
Configure a third-party application
For clients that support a custom OpenAI-compatible endpoint, start with these settings and validate the integration:
If the client asks for a full chat endpoint, use
https://api.llm.sg/v1/chat/completions. Some clients append /v1 themselves. Check the resulting request URL if you encounter path errors.