OpenAI Compatible

Chat Completions (OpenAI-compatible)

Changed on

OpenAI-compatible chat completions endpoint. Accepts the standard OpenAI request schema and returns the standard OpenAI response schema. Supports both streaming (SSE) and non-streaming modes. Works as a drop-in replacement with the OpenAI Python and TypeScript SDKs.

post/v1/chat/completions

Request

  • Base URL
    https://api.swarms.world
  • URL
    https://api.swarms.world/v1/chat/completions
  • Auth
    none declared. Required headers: x-api-key

Headers

x-api-keystring required

Request body

modelstring required

Model to use for completion

temperaturenumber nullable

Sampling temperature (0 to 2)

top_pnumber nullable

Nucleus sampling parameter

ninteger nullable

Number of completions to generate

streamboolean nullable

Whether to stream partial results

max_tokensinteger nullable

Maximum tokens to generate

max_completion_tokensinteger nullable

Maximum completion tokens (takes precedence over max_tokens)

presence_penaltynumber nullable

Presence penalty

frequency_penaltynumber nullable

Frequency penalty

userstring nullable

Unique identifier for the end-user

max_loopsinteger nullable

Maximum number of agent reasoning loops (Swarms extension). Defaults to 1 (single pass), at most 50. Use via extra_body in the OpenAI SDK.

toolsobject[] nullable

Function-calling tool definitions, in OpenAI schema

Response

Successful Response

idstring required
objectstring
createdinteger required
modelstring required

Changes

    • info

      added the new optional request property

    • breaking

      response property choices/items/finish_reason list-of-types was widened by adding types null to media type application/json of response 200

    • info

      added the new optional request property //

    • info

      added the new optional request property //

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added the optional property /// to the response with the status

    • info

      added the optional property /// to the response with the status