1 Overview
BLTYAPI provides an interface that is fully compatible with the OpenAI API. You can use any OpenAI-compatible SDK or HTTP client to connect directly, with no code changes required.
Base URL
https://api.jdlbags.com/v1
Supported Endpoints
POST /v1/chat/completions— Chat CompletionsGET /v1/models— List Models
2 Authentication
All API requests must include an Authorization
Bearer Token in the HTTP header. You can obtain your API Key from the BLTYAPI dashboard.
Request Header Format
Authorization: Bearer <YOUR_BLTYAPI_KEY>
3 Chat Completions
Send a POST request to /v1/chat/completions
to get a model-generated response. This endpoint is fully compatible with OpenAI's Chat Completions format.
cURL Example
curl https://api.jdlbags.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_BLTYAPI_KEY" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a poem about the ocean."}
],
"temperature": 0.7,
"max_tokens": 1024
}' | jq .
Python Example
from openai import OpenAI
client = OpenAI(
base_url="https://api.jdlbags.com/v1",
api_key="YOUR_BLTYAPI_KEY"
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a poem about the ocean."}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
Response Example
{
"id": "chatcmpl-9a8b7c6d5e4f3a2b1c0d",
"object": "chat.completion",
"created": 1734567890,
"model": "deepseek-chat",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "碧波万顷接天流,\n浪涌千层送远舟。\n日月沉浮皆过客,\n一怀浩气写春秋。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 30,
"completion_tokens": 32,
"total_tokens": 62
}
}
Streaming
Set stream: true
to enable Server-Sent Events (SSE) streaming output, receiving content token by token.
from openai import OpenAI
client = OpenAI(
base_url="https://api.jdlbags.com/v1",
api_key="YOUR_BLTYAPI_KEY"
)
stream = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Introduce Shanghai in 50 words."}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
4 Models
Query the list of available models. This endpoint is compatible with the OpenAI Models API format.
Request Method
GET https://api.jdlbags.com/v1/models
Available Models
cURL Query Example
curl https://api.jdlbags.com/v1/models \\\
-H "Authorization: Bearer YOUR_BLTYAPI_KEY" | jq .
Python: List Models
from openai import OpenAI
client = OpenAI(
base_url="https://api.jdlbags.com/v1",
api_key="YOUR_BLTYAPI_KEY"
)
models = client.models.list()
for model in models:
print(f"{model.id} - {model.owned_by}")
5 Error Codes
BLTYAPI follows the OpenAI error format for returning error information. Below are common error codes and how to handle them:
| HTTP Status | Error Type | Description | Resolution |
|---|---|---|---|
| 400 | invalid_request_error |
Request format error or missing parameters | Check request body JSON format and required fields |
| 401 | authentication_error |
API Key is invalid or missing | Check the Authorization request header |
| 403 | permission_error |
API Key lacks permission to access this model | Verify the model access permissions for your API Key |
| 404 | not_found_error |
Requested endpoint or model does not exist | Check the URL and model name |
| 429 | rate_limit_error |
Request rate limit exceeded | Reduce request frequency, check Retry-After response header |
| 500 | server_error |
Internal server error | Retry later; if the issue persists, contact support |
{
"error": {
"message": "Incorrect API key provided: sk-***. You can find your API key at ...",
"type": "authentication_error",
"param": null,
"code": "invalid_api_key"
}
}
6 Rate Limits
To ensure service stability, BLTYAPI enforces rate limits on API requests. Requests exceeding the limit will return
429 Too Many Requests.
60
Requests per minute (RPM)
100K
Tokens per minute (TPM)
50
Concurrent requests (RPC)
Response Headers
| Header | Description |
|---|---|
X-RateLimit-Limit |
Maximum number of requests allowed per minute |
X-RateLimit-Remaining |
Number of requests remaining in the current time window |
X-RateLimit-Reset |
Unix timestamp when the rate limit resets |
Retry-After |
Recommended wait time in seconds after being rate limited |
429, gradually increase the wait time to avoid adding load to the server.