Tip
A managed version of BricksLLM is also available! It is production ready, and comes with a dashboard to make interacting with BricksLLM easier. Try us out for free today!
BricksLLM is a cloud native AI gateway written in Go. Currently, it provides native support for OpenAI, Anthropic, Azure OpenAI and vLLM. BricksLLM aims to provide enterprise level infrastructure that can power any LLM production use cases. Here are some use cases for BricksLLM:
- Set LLM usage limits for users on different pricing tiers
- Track LLM usage on a per user and per organization basis
- Block or redact requests containing PIIs
- Improve LLM reliability with failovers, retries and caching
- Distribute API keys with rate limits and cost limits for internal development/production use cases
- Distribute API keys with rate limits and cost limits for students
- PII detection and masking
- Rate limit
- Cost control
- Cost analytics
- Request analytics
- Caching
- Request Retries
- Failover
- Model access control
- Endpoint access control
- Native support for all OpenAI endpoints
- Native support for Anthropic
- Native support for Azure OpenAI
- Native support for vLLM
- Native support for Deepinfra
- Support for custom deployments
- Integration with custom models
- Datadog integration
- Logging with privacy control
The easiest way to get started with BricksLLM is through BricksLLM-Docker.
git clone https://github.com/bricks-cloud/BricksLLM-Dockercd BricksLLM-Dockerdocker compose upYou can run this in detach mode use the -d flag: docker compose up -d
curl -X PUT http://localhost:8001/api/provider-settings \
-H "Content-Type: application/json" \
-d '{
"provider":"openai",
"setting": {
"apikey": "YOUR_OPENAI_KEY"
}
}' Copy the id from the response.
Use id from the previous step as settingId to create a key with a rate limit of 2 req/min and a spend limit of 25 cents.
curl -X PUT http://localhost:8001/api/key-management/keys \
-H "Content-Type: application/json" \
-d '{
"name": "My Secret Key",
"key": "my-secret-key",
"tags": ["mykey"],
"settingIds": ["ID_FROM_STEP_FOUR"],
"rateLimitOverTime": 2,
"rateLimitUnit": "m",
"costLimitInUsd": 0.25
}' Then, just redirect your requests to us and use OpenAI as you would normally. For example:
curl -X POST http://localhost:8002/api/providers/openai/v1/chat/completions \
-H "Authorization: Bearer my-secret-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "hi"
}
]
}'Or if you're using an SDK, you could change its baseURL to point to us. For example:
// OpenAI Node SDK v4
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: "some-secret-key", // key created earlier
baseURL: "http://localhost:8002/api/providers/openai/v1", // redirect to us
});For updating to the latest version
docker pull luyuanxin1995/bricksllm:latestFor updating to a particular version
docker pull luyuanxin1995/bricksllm:1.4.0
Name type description default POSTGRESQL_HOSTSrequired Hosts for Postgresql DB. Separated by , localhostPOSTGRESQL_DB_NAMEoptional Name for Postgresql DB. POSTGRESQL_USERNAMErequired Postgresql DB username POSTGRESQL_PASSWORDrequired Postgresql DB password POSTGRESQL_SSL_MODEoptional Postgresql SSL mode disablePOSTGRESQL_PORToptional The port that Postgresql DB runs on 5432POSTGRESQL_READ_TIME_OUToptional Timeout for Postgresql read operations 2mPOSTGRESQL_WRITE_TIME_OUToptional Timeout for Postgresql write operations 5sREDIS_HOSTSrequired Host for Redis. Separated by , localhostREDIS_PASSWORDoptional Redis Password REDIS_PORToptional The port that Redis DB runs on 6379REDIS_READ_TIME_OUToptional Timeout for Redis read operations 1sREDIS_WRITE_TIME_OUToptional Timeout for Redis write operations 500msIN_MEMORY_DB_UPDATE_INTERVALoptional The interval BricksLLM API gateway polls Postgresql DB for latest key configurations 1sSTATS_PROVIDERoptional "datadog" or Host:Port(127.0.0.1:8125) for statsd. PROXY_TIMEOUToptional Timeout for proxy HTTP requests. 600sNUMBER_OF_EVENT_MESSAGE_CONSUMERSoptional Number of event message consumers that help handle counting tokens and inserting event into db. 3AWS_SECRET_ACCESS_KEYoptional It is for PII detection feature. 5sAWS_ACCESS_KEY_IDoptional It is for using PII detection feature. 5sAMAZON_REGIONoptional Region for AWS. us-west-2AMAZON_REQUEST_TIMEOUToptional Timeout for amazon requests. 5sAMAZON_CONNECTION_TIMEOUToptional Timeout for amazon connection. 10sADMIN_PASSoptional Simple password for the admin server.
