Completions
POST https://api.synthetic.new/openai/v1/completions
Create a completion for a provided prompt and parameters.
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
model | string | Yes | Model name (must be prefixed with hf: ). See supported Models. |
prompt | string/array | Yes | Text prompt(s) to generate completions for. Can be a string, array of strings, array of numbers, or array of arrays of numbers. |
echo | boolean | No | Echo back the prompt in addition to completion |
frequency_penalty | number | No | Penalty for token frequency (-2.0 to 2.0). Reduces repetition. |
logit_bias | object | No | Modify token likelihood. Maps token IDs to bias values (-100 to 100). |
logprobs | number | No | Include log probabilities on most likely tokens |
max_completion_tokens | number | No | Maximum tokens for completion |
max_tokens | number | No | Maximum number of tokens to generate |
min_p | number | No | Minimum probability for nucleus sampling |
n | number | No | Number of completions to generate (default: 1) |
presence_penalty | number | No | Penalty for token presence (-2.0 to 2.0). Encourages new topics. |
reasoning_effort | string | No | Control reasoning effort for thinking models: low , medium , or high |
stop | string/array | No | Stop sequence(s) |
stream | boolean | No | Stream response using server-sent events |
stream_options | object | No | Options for streaming (when stream: true ) |
temperature | number | No | Sampling randomness (0.0-2.0). Higher = more random. |
top_k | number | No | Limit sampling to top K tokens |
top_p | number | No | Nucleus sampling threshold (0.0-1.0) |
user | string | No | Unique identifier representing your end-user |
Example Request
- Python
- TypeScript
- curl
import openai
client = openai.OpenAI(
api_key="SYNTHETIC_API_KEY",
base_url="https://api.synthetic.new/openai/v1"
)
completion = client.completions.create(
model="hf:deepseek-ai/DeepSeek-V3-0324",
prompt="The future of artificial intelligence is",
max_tokens=50,
temperature=0.7,
stop=["\n"]
)
print(completion.choices[0].text)
Example Response
- json
{
"id": "49fb0537-dafc-441c-ad42-b4c4aa2f5193",
"object": "text_completion",
"created": 1757645512,
"model": "accounts/fireworks/models/deepseek-v3-0324",
"choices": [
{
"index": 0,
"text": " undeniably bright and holds the potential to revolutionize every aspect of our lives. As we stand on the cusp of technological advancements, AI is poised to become more sophisticated, integrated, and ethical. From transforming industries to enhancing daily conveniences, AI’",
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 7,
"total_tokens": 57,
"completion_tokens": 50
}
}
Multiple Prompts
You can send multiple prompts in a single request:
- Python
- TypeScript
- curl
completion = client.completions.create(
model="hf:deepseek-ai/DeepSeek-V3-0324",
prompt=[
"The capital of France is",
"The largest planet in our solar system is"
],
max_tokens=10
)
Streaming
When stream: true
is set, the response will be a series of Server-Sent Events:
- Python
- TypeScript
- curl
completion = client.completions.create(
model="hf:deepseek-ai/DeepSeek-V3-0324",
prompt="Once upon a time",
max_tokens=50,
stream=True
)
for chunk in completion:
if chunk.choices[0].text:
print(chunk.choices[0].text, end='', flush=True)
Streaming Response
data: {"id":"cmpl-abc123","object":"text_completion","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"text":" in","index":0,"finish_reason":null}]}
data: {"id":"cmpl-abc123","object":"text_completion","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"text":" a","index":0,"finish_reason":null}]}
data: {"id":"cmpl-abc123","object":"text_completion","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"text":" far","index":0,"finish_reason":"length"}],"usage":{"prompt_tokens":5,"total_tokens":55,"completion_tokens":50}}]}
data: [DONE]