POST
/
completions
OpenAI-compatible text completions
curl --request POST \
  --url https://modelslab.com/api/v6/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "ModelsLab/Llama-3.1-8b-Uncensored-Dare",
  "prompt": "<string>",
  "max_tokens": 128,
  "temperature": 1,
  "top_p": 1,
  "presence_penalty": 0,
  "frequency_penalty": 0,
  "stream": false,
  "stop": "<string>"
}'
{
  "object": "text_completion",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "text": "<string>",
      "index": 123,
      "logprobs": {},
      "finish_reason": "stop",
      "stop_reason": "<string>",
      "prompt_logprobs": {}
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

Request

curl
curl -X POST https://modelslab.com/api/uncensored-chat/v1/completions \  
-H "Authorization: Bearer $MODELSLAB_API_KEY" \  
-H "Content-Type: application/json"

Body

json
{
    "prompt": "Write a tagline for an ice cream shop.",
    "model": ""
}

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
     import os
     from openai import OpenAI

     MODELSLAB_API_KEY = os.getenv("MODELSLAB_API_KEY")
     client = OpenAI(
         api_key=MODELSLAB_API_KEY,
         base_url="https://modelslab.com/api/uncensored-chat/v1",
     )

     response = client.completions.create(
         model="ModelsLab/Llama-3.1-8b-Uncensored-Dare",
         prompt="Write a tagline for an ice cream shop."
     )

     print(response.choices[0].text)
3

Response

json
     {
         "object": "text_completion",
         "created": 1732624363,
         "model": "ModelsLab/Llama-3.1-8b-Uncensored-Dare",
         "choices": [
             {
                 "text": "\"Indulge in our destructive addiction of ice cream.\"",
                 "index": 0,
                 "logprobs": null,
                 "finish_reason": "length",
                 "stop_reason": null,
                 "prompt_logprobs": null
             }
         ],
         "usage": {
             "prompt_tokens": 122,
             "completion_tokens": 13,
             "total_tokens": 135
         }
     }

Authorizations

Authorization
string
header
required

Bearer token authentication using ModelsLab API key

Body

application/json
prompt
required

Prompt(s) to generate completions for

model
string
default:ModelsLab/Llama-3.1-8b-Uncensored-Dare

Model to use for completion

max_tokens
integer
default:128

Maximum number of tokens allowed in the response

Required range: 1 <= x <= 44000
temperature
number
default:1

Sampling temperature for randomness

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

Nucleus sampling parameter

Required range: 0 <= x <= 1
presence_penalty
number
default:0

Presence penalty for token repetition

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

Frequency penalty for token repetition

Required range: -2 <= x <= 2
stream
boolean
default:false

Whether to stream back partial progress

stop

Stop sequences to end generation

Response

Text completion response

object
enum<string>

Object type

Available options:
text_completion
created
integer

Unix timestamp of creation

model
string

Model used for generation

choices
object[]

Array of completion choices

usage
object

Token usage information