Testing with Postman
Postman is a popular API client that makes it easy to test API endpoints. This guide walks you through how to use Postman to test the Ultrasafe API with UltraSafe models.
Setting Up Postman
- Download and install Postman - If you don't already have Postman, download it from postman.com.
- Create a new Collection - In Postman, click on "Collections" and then the "+" button to create a new collection named "Ultrasafe AI API".
- Add your API key as a variable - Click on the three dots next to your collection name, select "Edit," then go to the "Variables" tab. Add a variable named "api_key" with your API key as the value.
Setting Up Headers
You'll need to set up the following headers in Postman for the UltraSafe API:
| Header | Value | Description | 
|---|---|---|
| Content-Type | application/json | Specifies that the request body is in JSON format | 
| Authorization | Bearer <API-KEY> | Your API key prefixed with "Bearer " | 
TIP: In Postman, you can use variables to avoid hardcoding your API key. Use Bearer {api_key} as the Authorization header value.
Testing the UltraSafe API
The UltraSafe API uses a single endpoint for all UltraSafe models.
Request Setup
- Create a new request - In your collection, click "Add request" and name it "V2 Chat Completion".
- Set the request method and URL:- Method: POST
- URL: https://app.us.inc/api/v2/chat/completions
 
- Add headers - Under the "Headers" tab, add the Content-Type and Authorization headers as described above.
- Add request body - Under the "Body" tab, select "raw" and choose "JSON" from the dropdown. Then add the JSON request:
Request Body Example:
1{
2    "model": "ultrasafe/usf-mini",
3    "messages": [
4        {
5            "role": "user",
6            "content": "hello, how are you?"
7        }
8    ],
9    "temperature": 0.7,
10    "max_tokens": 1000,
11    "top_p": 1.0,
12    "web_search": false,
13    "stream": false
14}Response Example
1{
2    "model": "ultrasafe/usf-mini",
3    "id": "ultrasafe-id_yNwd8EyBzJJO1W2nV",
4    "conversation_id": null,
5    "choices": [
6        {
7            "index": 0,
8            "finish_reason": "stop",
9            "message": {
10                "role": "assistant",
11                "content": "Hello! I'm functioning optimally today, thank you for asking. How can I assist you?"
12            }
13        }
14    ],
15    "token_metrics": {
16        "input_tokens": 125,
17        "output_tokens": 21,
18        "total_tokens": 146
19    }
20}Tips for Effective Testing
Using Environment Variables
Use Postman environment variables to easily switch between development and production environments.
- Create variables for your API base URL
- Store different API keys for different environments
- Reference variables using {variable_name}syntax
Testing Streaming Responses
To test streaming responses:
- Set "stream": truein your request body
- In Postman, check the "Response is a streamed result" option under the "Body" tab
- Run the request and you'll see chunks of the response as they arrive
Troubleshooting
Common Issues
401 Unauthorized
Check that your API key is valid and properly formatted in the Authorization header (should be Bearer YOUR_API_KEY).
400 Bad Request
Ensure your request body is properly formatted JSON and contains all required fields.
404 Not Found
Verify that the model ID exists and that you're using the correct endpoint (v1 or v2) for the model you're trying to use.