Completions API¶
Generate text completions with Amazon Bedrock foundation models—including Claude, Nova, Llama, and more—through an OpenAI-compatible interface using the simple completions format.
Legacy upstream, first-class here
OpenAI labels /v1/completions as legacy in their platform documentation and recommends new OpenAI projects migrate to /v1/chat/completions or /v1/responses for vendor compatibility. On stdapi.ai, this endpoint is a first-class route with the same quality guarantees as the others — its compact schema and small token footprint make it an excellent pick for MCP-based text agents and simple prompt-to-text workloads.
Why Choose the Completions API?¶
-
Smallest Token Footprint
The most compact request/response schema of the text APIs — ideal for MCP-based text agents and high-volume prompt-to-text workloads. -
Batch Prompts
Send multiple independent prompts in one request and get one choice back per prompt, with streaming support. -
Multimodal Prompt Inputs
Reference prompts and files viahttps://,s3://,data:, orfile-id:URIs — including images, documents, audio, and video. -
AWS Scale & Reliability
Run on AWS infrastructure with service tiers and multi-region model access for availability and performance.
Available Endpoints¶
| Endpoint | Method | What It Does | Powered By | MCP Tool |
|---|---|---|---|---|
/v1/completions | POST | Simple prompt-to-text completion | Amazon Bedrock Converse API · Amazon Bedrock Mantle | openai_completion |
Feature Compatibility¶
| Feature | Status | Notes |
|---|---|---|
| Prompt Input | ||
| Single text prompt | Full support for string prompts | |
| Multiple prompts (batch) | Returns one choice per prompt; rejected with 400 on Mantle-served models | |
| Text + files collapse (multimodal) | [text, file, …] sent as one multimodal request with one choice | |
Prompt from URL (https://) | HTTP URL reference | |
Prompt from S3 (s3://) | S3 URI reference | |
Prompt from data URI (data:) | Base64-encoded data URI | |
Prompt from Files API (file-id:) | Reference uploaded files | |
| Token array prompts | Not supported — use string prompts; rejected with 400 | |
| Generation Control | ||
max_tokens | Output length limits | |
temperature | Mapped to Bedrock inference params | |
top_p | Nucleus sampling control | |
stop sequences | Custom stop strings; dropped when a Mantle request is converted to the Responses API | |
n (multiple choices) | Supported with and without streaming; n > 1 rejected with 400 when a Mantle request is converted to the Responses or Messages API | |
best_of | Accepted but ignored | |
echo | Accepted but ignored; rejected with 400 on Mantle-served models | |
frequency_penalty | Accepted but ignored | |
presence_penalty | Accepted but ignored | |
logit_bias | Accepted but ignored | |
logprobs | Accepted but ignored; rejected with 400 on Mantle-served models | |
seed | Accepted but ignored | |
suffix | Accepted but ignored; rejected with 400 on Mantle-served models | |
| Streaming | ||
Streaming (stream: true) | Server-Sent Events (SSE) | |
stream_options.include_usage | Usage in final chunk | |
| Streaming with multiple prompts | Deltas interleave; choices[0].index identifies the prompt | |
| Streaming with n>1 | Deltas interleave; choices[0].index identifies each choice | |
| Other | ||
| Service tiers | Mapped to Bedrock service tiers; service_tier and prompt_cache_* are not forwarded when a Mantle request is converted | |
user / safety_identifier | Forwarded to Amazon Bedrock as requestMetadata; on Mantle, user is forwarded as the OpenAI user field (as metadata.user_id when served via the Anthropic API) and safety_identifier is not forwarded | |
| Extra model-specific params | Unrecognized top-level keys are forwarded to the model as provider-specific fields; model_id, additional_request_fields and stop_sequences are reserved by the gateway and rejected with a 400 invalid_request_error naming the key (use stop for stop sequences) |
Legend:
- Supported — Fully compatible with OpenAI API
- Model-Dependent — Behavior depends on the model or backend; check the Notes column
- Partial — Supported with limitations
- Unsupported — Not available in this implementation
- Extra Feature — Enhanced capability beyond OpenAI API
Model Support¶
Every model the Chat Completions API serves also answers here — the same model classes back both routes, with the prompt adapted into a single Converse turn. That means all models supported by the Amazon Bedrock Converse and Converse Stream API, plus every model served by Bedrock Mantle when enabled. The Mantle conversion behavior tabled above is the same three serving paths described on the Chat Completions page.
To list the models this deployment serves on this route, call search_models with route=openai_completion.
Model Name Aliases¶
The dynamic aliases published by the official provider APIs resolve here too, exactly as they do for chat — gpt-oss-20b reaches openai.gpt-oss-20b-1:0.
Prompt Input Types¶
stdapi.ai extends the standard completions interface with multiple input modes:
String Prompt (Standard)¶
The simplest input — a single text prompt:
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "The capital of France is",
"max_tokens": 20
}'
Batch Prompts¶
Send multiple independent prompts in a single request — the server returns one choices[] entry per prompt:
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": ["One plus one is", "Two plus two is", "Three plus three is"],
"max_tokens": 10
}'
Text + Files: Single-Request Multimodal Collapse¶
When the prompt list contains exactly one text string and one or more file references, stdapi.ai packs them in input order into a single multimodal request and returns one choice. The text becomes a text block and each file becomes an image / document / audio / video Bedrock block (content type auto-detected) — the natural "ask once using these files as context" pattern.
- Trigger: list with exactly one
strelement and ≥1 URL elements (https://,s3://,data:,file-id:). - Effect: elements are resolved concurrently, packed as Bedrock content blocks preserving input order, and sent as a single request. You get one
Completionchoice back. - Requires: a model that supports the target modalities (e.g. Claude, Nova for image / document input).
- Unchanged otherwise: any other shape returns one
Completionchoice per list element. Eachstrbecomes atextblock; eachInputFileUrlbecomes the content block matching its detected MIME type (image, video, audio, document). See Files-only prompts below.
Image analysis with a base64 data URI (Claude handles image input):
IMAGE_B64=$(base64 < chart.png | tr -d '\n')
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<JSON
{
"model": "anthropic.claude-haiku-4-5-20251001-v1:0",
"prompt": [
"Describe what is shown in this chart in one short sentence:",
"data:image/png;base64,${IMAGE_B64}"
],
"max_tokens": 80
}
JSON
Or, referencing previously uploaded files via file-id::
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic.claude-haiku-4-5-20251001-v1:0",
"prompt": [
"Summarize the main findings and cross-reference with the appendix:",
"file-id:file-abc123",
"file-id:file-def456"
],
"max_tokens": 400
}'
Input order is preserved — place the instruction before, after, or between the files as best fits your use case.
Files-Only Prompts¶
When the prompt is a lone file — or a list of files without any text string — stdapi.ai forwards each file to the model using its detected modality (image, video, audio, document). No instruction is injected:
prompt: "<file-id or URL>"→ one request, one choice, with a single media block.prompt: [<file1>, <file2>, …]→ one request per file (batch), one choice per file, each carrying its own media block.
The request reaches the model as-is; the model returns output or an error depending on whether it supports that modality (for example, Claude handles images and documents, Nova handles images, video, and documents). Use this shape for quick "what is this?" queries where the model's default behavior is enough; for tighter control over the response, prefer the collapse pattern above with an explicit instruction.
IMAGE_B64=$(base64 < screenshot.png | tr -d '\n')
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<JSON
{
"model": "anthropic.claude-haiku-4-5-20251001-v1:0",
"prompt": "data:image/png;base64,${IMAGE_B64}",
"max_tokens": 120
}
JSON
URL, S3, and Files API Inputs (Extension)¶
stdapi.ai supports additional input schemes beyond the OpenAI standard:
https://— Load prompt from an HTTP URLs3://bucket/key/file.txt— Load directly from S3data:text/plain;base64,...— Embedded base64 datafile-id:file-abc123— Reference files uploaded via the Files API
Using file-id: for Prompt Input¶
Reference files uploaded via the Files API using the file-id: URI scheme. Useful for long prompts or when reusing the same prompt across multiple requests:
# Upload a text file
FILE_ID=$(curl -s -X POST "$BASE/v1/files" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F "purpose=assistants" \
-F "file=@prompt.txt" | jq -r .id)
# Reference it in a completion request
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"amazon.nova-micro-v1:0\",
\"prompt\": \"file-id:${FILE_ID}\",
\"max_tokens\": 100
}"
Using S3 for Prompt Input¶
Reference files directly in S3 without uploading to stdapi.ai:
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "s3://my-bucket/prompts/essay-topic.txt",
"max_tokens": 500
}'
The gateway reads the file from S3 using your configured IAM role — no pre-signed URLs required.
Streaming¶
Set "stream": true to receive incremental text deltas as Server-Sent Events terminated by data: [DONE]:
curl -N -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "Write a short story",
"max_tokens": 100,
"stream": true
}'
Usage in Streaming Responses¶
Request usage statistics on the final chunk by setting stream_options.include_usage:
curl -N -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "Hello",
"stream": true,
"stream_options": {"include_usage": true}
}'
Available Request Headers¶
This endpoint supports standard Bedrock headers for enhanced control over your requests — they are applied by the shared request middleware, exactly as on the Chat Completions API. All headers are optional and can be combined as needed.
Content Safety (Guardrails)¶
| Header | Purpose | Valid Values |
|---|---|---|
X-Amzn-Bedrock-GuardrailIdentifier | Guardrail ID for content filtering | Your guardrail identifier |
X-Amzn-Bedrock-GuardrailVersion | Guardrail version | Version number (e.g., 1) |
X-Amzn-Bedrock-Trace | Guardrail trace level | disabled, enabled, enabled_full |
Performance Optimization¶
| Header | Purpose | Valid Values |
|---|---|---|
X-Amzn-Bedrock-Service-Tier | Service tier selection | default, flex, priority, reserved |
X-Amzn-Bedrock-PerformanceConfig-Latency | Latency optimization | standard, optimized |
Detailed Documentation
For complete information about these headers, configuration options, and use cases, see:
Model-Specific Features¶
TwelveLabs Pegasus¶
twelvelabs.pegasus-1-2-v1:0 is a video-understanding model. The Completions endpoint supports multimodal input: pass an array with exactly one text instruction and one video URL as prompt — the server combines them into a single Pegasus request.
temperatureandmax_tokensare forwarded.- A text-only
promptwithout a video returns HTTP 400 (Pegasus requires exactly one video).
Video input formats: s3://bucket/key, https://…, data:video/mp4;base64,…, or file-id:…. Videos above 18.75 MB are automatically uploaded to S3.
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "twelvelabs.pegasus-1-2-v1:0",
"prompt": ["Describe what happens in this video.", "s3://my-bucket/video.mp4"]
}'
Try It Now¶
Send your first completion in one line — then explore the richer input modes shown in Prompt Input Types above:
curl -X POST "$BASE/v1/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "amazon.nova-micro-v1:0",
"prompt": "Say hello world",
"max_tokens": 20
}'
Ready to build with AI? Check out the Models API to see all available foundation models!