Before you begin: Generate an Admin JWT
To interact with the Admin API (control plane), you need a valid JWT. Use the repository script to generate it: Script: scripts/generate_jwt_token.sh Requirement: The environment variable SERVER_SECRET_KEY must be set, and it must be exactly the same value used when starting TrustGate. If these differ, the generated JWT will be rejected by the control plane. Example:-
Set the server secret (must match the value used to start TrustGate):
export SERVER_SECRET_KEY="your-secure-shared-secret"
-
Generate the admin JWT (the script prints a token to stdout; you can capture it into an env var):
export ADMIN_JWT=$(bash scripts/generate_jwt_token.sh)
-
Use the token in Admin API requests, e.g.:
curl -H "Authorization: Bearer $ADMIN_JWT" http://localhost:8080/api/v1/gateways
-H "Authorization: Bearer $ADMIN_JWT"
.
Step 1: Create a Gateway
Set up your first gateway instance with rate limiting configuration
Step 1: Create a Gateway
Set up your first gateway instance with rate limiting configuration
Use the Admin API to create your first gateway:
Verify Gateway Creation
Check if your gateway was created successfully:Step 2: Create The Upstream
Configure upstream providers like OpenAI and Anthropic with load balancing
Step 2: Create The Upstream
Configure upstream providers like OpenAI and Anthropic with load balancing
Step 3: Create the Service
Set up a service to handle routing and manage upstream connections
Step 3: Create the Service
Set up a service to handle routing and manage upstream connections
Create your service using the Admin API:
Verify Configuration
Check that your service is properly configured:Step 4: Create a Rule
Define routing rules to direct traffic to your service
Step 4: Create a Rule
Define routing rules to direct traffic to your service
Create your first rule using the Admin API:
Verify Rules
Check that your rules are properly configured:Step 5: Test the Rules
Verify your configuration by making test requests to the gateway
Step 5: Test the Rules
Verify your configuration by making test requests to the gateway
Test your rule configurations:API Key (optional): If you plan to use API key authentication, create one in the Final Step below and set the
X-TG-API-Key
header to your key.Final Step: Create an API Key
Generate an API key for authentication and access control
Final Step: Create an API Key
Generate an API key for authentication and access control
Next steps:
Now that you have configured your rules, read more about:- Learn about Load Balancing
- Explore Rate Limiting
Troubleshooting
Common issues and solutions:- Routing Issues
- Verify path patterns
- Check method restrictions
- Review rule priorities
- Path Handling
- Check strip_path setting
- Verify preserve_host
- Test path transformations
- Header Problems
- Verify header requirements
- Check header values
- Test header matching