Quick start
1
Set your API key
Replace
YOUR_API_KEY with your actual API key from the cloro dashboard.2
Make a basic request
Send a POST request to the ChatGPT API endpoint.
3
Process the response
The API returns a JSON response that you can pipe to other commands or save to a file.
Complete example
Request headers
You must include these headers in every request:The
Authorization header must use the Bearer scheme with your API key. The Content-Type header tells the API that you’re sending JSON data.Formatting the JSON payload
When using cURL, you have several options for formatting your JSON payload:Inline JSON
For simple requests, you can include the JSON directly in the command:Multi-line JSON
For better readability, use multi-line formatting:External JSON file
For complex payloads or reusable requests, use an external file:Request parameters
Customize your API request using these parameters in the JSON payload:The
prompt parameter is mandatory. All other parameters are optional.Handling the response
The API returns a JSON response with this structure:Save response to file
Pretty print with jq
Extract specific fields
Timeout configuration
Error handling best practices
Implement robust error handling in your shell scripts:Checking response status
Always verify the HTTP status code and thestatus field:
Shell script integration
Here’s a complete example of integrating the API into a shell script:Always validate the response structure and check for the
success status before attempting to access nested fields.Next steps
- Explore the API reference for detailed endpoint documentation
- Learn about shopping card extraction for e-commerce data
- Check out advanced features like query fan-out insights