Moderations and Legacy Completions
These two interfaces are primarily for compatibility with existing applications. For new projects that only need chat, prioritize using /v1/chat/completions.
Content Moderation - Moderations
Moderations are used to determine if input text triggers safety categories. Actual categories, thresholds, and return fields depend on the selected model or channel.
| Configuration | Value |
|---|---|
| Endpoint | https://api.corerouter.cloud/v1/moderations |
| Header | Authorization: Bearer sk-... |
| Required Field | input |
| Optional Field | model |
If model is not passed, the system may use a default moderation model. Production environments should explicitly fill in moderation model IDs from the console.
bash
export COREROUTER_API_KEY="sk-xxxxxxxxxxxxxxxx"
curl https://api.corerouter.cloud/v1/moderations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"model": "moderation-model-id",
"input": "User input that needs to be moderated goes here."
}'Common uses:
- Pre-publication review of user content.
- Pre-check of conversation input.
- Secondary review of model output.
- Different blocking strategies for different business scenarios.
Legacy Completions
/v1/completions is the legacy text completion interface. Request field is typically prompt, not Chat Completions' messages.
| Configuration | Value |
|---|---|
| Endpoint | https://api.corerouter.cloud/v1/completions |
| Header | Authorization: Bearer sk-... |
| Required Fields | model, prompt |
| Recommendation | Only for legacy application compatibility |
bash
curl https://api.corerouter.cloud/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $COREROUTER_API_KEY" \
-d '{
"model": "completion-model-id",
"prompt": "Complete this sentence: CoreRouter can help developers",
"max_tokens": 128
}'Difference Between Chat Completions and Completions
| Interface | Input Field | Suitable Scenarios |
|---|---|---|
/v1/chat/completions | messages | New applications, chat, multi-turn conversation, tool calling, vision understanding |
/v1/completions | prompt | Legacy application compatibility, simple text continuation |
Don't pass messages to /v1/completions, and don't use prompt as the main input for /v1/chat/completions.
Common Issues
field input is required: Moderations missinginput.field prompt is required: Completions missingprompt.- Moderation model unavailable: Check if console provides moderation models, or explicitly switch to an available model.
- Legacy SDK error: Confirm it's calling
/v1/completions; Base URL should behttps://api.corerouter.cloud/v1.
