curl --request POST \
--url https://ai.megallm.io/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}
'{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 123,
"model": "gpt-4",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "Invalid request parameters",
"type": "invalid_request_error",
"code": "invalid_parameters"
}
}{
"error": {
"message": "Invalid authentication credentials",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}{
"error": {
"message": "Rate limit exceeded. Please retry after some time.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "Internal server error",
"type": "api_error",
"code": "internal_error"
}
}Chat & Messages
Create chat completion
Generate conversational AI responses using the OpenAI-compatible chat completions API
POST
/
chat
/
completions
curl --request POST \
--url https://ai.megallm.io/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
]
}
'{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 123,
"model": "gpt-4",
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"name": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "Invalid request parameters",
"type": "invalid_request_error",
"code": "invalid_parameters"
}
}{
"error": {
"message": "Invalid authentication credentials",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}{
"error": {
"message": "Rate limit exceeded. Please retry after some time.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "Internal server error",
"type": "api_error",
"code": "internal_error"
}
}Authorizations
Bearer token authentication (OpenAI-compatible)
Body
application/json
Model ID (e.g., gpt-4, claude-3.5-sonnet)
Example:
"gpt-4"
Array of message objects
Show child attributes
Show child attributes
Sampling temperature (0.0 - 2.0)
Required range:
0 <= x <= 2Maximum tokens to generate
Enable streaming responses
Available functions/tools
Show child attributes
Show child attributes
Controls tool calling behavior
Available options:
auto, required, none Nucleus sampling parameter
Required range:
0 <= x <= 1Penalize frequent tokens
Required range:
-2 <= x <= 2Penalize repeated tokens
Required range:
-2 <= x <= 2Number of completions to generate
Stop sequences
Unique user identifier
Was this page helpful?

