Skip to main content
POST
Chat Completions

Request

curl

Body

json

OpenAI SDK

This endpoint offers compatibility with the OpenAI SDKs to support developers and their apps with minimal changes. Once you update the base URL, you can start using the SDKs to make calls to Modelslab with API key.
1

Import the package

You can import the OpenAI python package into your python application and change the base URL and API key.pip install openai
2

Python code

python
3

Response

json

Authorizations

Authorization
string
header
required

Bearer token authentication using ModelsLab API key

Body

application/json
messages
object[]
required

Array of chat messages

model
string

Model ID to use for the completion (e.g. 'Qwen/Qwen2.5-VL-72B-Instruct-together')

max_tokens
integer
default:1000

Maximum number of tokens to generate

Required range: x >= 1
temperature
number
default:1

Sampling temperature (0-2). Higher values make output more random.

Required range: 0 <= x <= 2
top_p
number
default:1

Nucleus sampling parameter

Required range: 0 <= x <= 1
stream
boolean
default:false

Whether to stream partial results as Server-Sent Events

presence_penalty
number
default:0

Penalize new tokens based on whether they appear in the text so far

Required range: -2 <= x <= 2
frequency_penalty
number
default:0

Penalize new tokens based on their frequency in the text so far

Required range: -2 <= x <= 2

Response

Chat completion response

id
string

Unique completion ID

object
enum<string>
Available options:
chat.completion
created
integer

Unix timestamp

model
string

Model used

choices
object[]
usage
object