synthetic
    API
    • Overview
    • Getting Started
    • Models
    OpenAI Reference
    • /models
    • /chat/completions
    • /completions
    • /embeddings
    Anthropic Reference
    • /messages
    • /messages/count_tokens
    Synthetic Reference
    • /quotas
    Guides
    • Claude Code
    • Octofriend by Synthetic
    • Xcode Intelligence
    • Back to app

    Chat Completions

    POST https://api.synthetic.new/openai/v1/chat/completions

    Create a model response for a given chat conversation.

    Request Body

    ParameterTypeRequiredDescription
    messagesarrayYesList of messages comprising the conversation
    modelstringYesModel name (must be prefixed with hf:). See supported Models.
    frequency_penaltynumberNoPenalty for token frequency (-2.0 to 2.0). Reduces repetition.
    logit_biasobjectNoModify token likelihood. Maps token IDs to bias values (-100 to 100).
    logprobsboolean/numberNoReturn log probabilities of output tokens
    max_completion_tokensnumberNoMaximum tokens for completion (including reasoning tokens)
    max_tokensnumberNoMaximum number of tokens to generate
    min_pnumberNoMinimum probability for nucleus sampling
    nnumberNoNumber of completion choices to generate (default: 1)
    parallel_tool_callsbooleanNoEnable parallel function calling during tool use
    presence_penaltynumberNoPenalty for token presence (-2.0 to 2.0). Encourages new topics.
    reasoning_effortstringNoControl reasoning effort for thinking models: low, medium, or high
    response_formatobjectNoSpecify output format (JSON schema, JSON object, etc.)
    seednumberNoRandom seed for deterministic sampling
    stopstring/arrayNoStop sequence(s)
    streambooleanNoStream response using server-sent events
    stream_optionsobjectNoOptions for streaming (when stream: true)
    temperaturenumberNoSampling randomness (0.0-2.0). Higher = more random.
    tool_choicestring/objectNoControl tool calling: auto, none, or specific tool
    toolsarrayNoList of tools the model may call
    top_knumberNoLimit sampling to top K tokens
    top_logprobsnumberNoNumber of top token probabilities to return
    top_pnumberNoNucleus sampling threshold (0.0-1.0)
    userstringNoUnique identifier representing your end-user
    function_callstring/objectNo(Deprecated) Control function calling: auto, none, or specific function
    functionsarrayNo(Deprecated) List of functions the model may call

    Message Object

    ParameterTypeRequiredDescription
    rolestringYesRole: system, user, assistant, tool, or function
    contentstring/arrayYesMessage content (text string or array of content parts)
    namestringNoName of the participant (for user/system messages)
    tool_callsarrayNoTool calls to be executed (for assistant messages)
    tool_call_idstringNoID of the tool call (for tool messages)
    reasoning_contentstringNoReasoning content for thinking models (for assistant messages)
    function_callobjectNo(Deprecated) Function call to be executed (for assistant messages)

    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.chat.completions.create(
      model="hf:deepseek-ai/DeepSeek-V3-0324",
      messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"}
      ],
      max_tokens=100,
      temperature=0.7
    )
    
    print(completion.choices[0].message.content)

    Example Response

    • json
    {
      "id": "296a8fcb-181d-46d4-ad9b-b380befa9a07",
      "object": "chat.completion",
      "created": 1757644754,
      "model": "accounts/fireworks/models/deepseek-v3-0324",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "The capital of France is **Paris**. \n\nParis is known for its rich history, iconic landmarks like the Eiffel Tower and the Louvre Museum, and its cultural significance as a global hub for art, fashion, and cuisine. \n\nLet me know if you'd like more details!"
          },
          "finish_reason": "stop"
        }
      ],
      "usage": {
        "prompt_tokens": 16,
        "total_tokens": 74,
        "completion_tokens": 58
      }
    }
    

    Streaming

    When stream: true is set, the response will be a series of Server-Sent Events:

    • Python
    • TypeScript
    • curl
    completion = client.chat.completions.create(
      model="hf:deepseek-ai/DeepSeek-V3-0324",
      messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Tell me a short story."}
      ],
      max_tokens=100,
      stream=True
    )
    
    for chunk in completion:
      if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end='', flush=True)

    Streaming Response

    data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"index":0,"delta":{"role":"assistant","content":"Once"},"finish_reason":null}]}
    
    data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"index":0,"delta":{"content":" upon"},"finish_reason":null}]}
    
    data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"index":0,"delta":{"content":" a"},"finish_reason":null}]}
    
    data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1757644754,"model":"accounts/fireworks/models/deepseek-v3-0324","choices":[{"index":0,"delta":{},"finish_reason":"length"}],"usage":{"prompt_tokens":20,"total_tokens":120,"completion_tokens":100}}
    
    data: [DONE]