Skip to main content
POST
https://api.keywordsai.co
/
api
/
models
import requests

url = "https://api.keywordsai.co/api/models/"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
payload = {
    "model_name": "my-custom-gpt-4",
    "base_model_name": "gpt-4",
    "display_name": "My Custom GPT-4",
    "custom_provider_id": "my-azure-provider",
    "input_cost": 0.025,
    "output_cost": 0.075
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
{
  "id": "my-custom-gpt-4",
  "model_name": "my-custom-gpt-4",
  "display_name": "My Custom GPT-4",
  "base_model_name": "gpt-4",
  "affiliation_category": "custom",
  "is_called_by_custom_name": false,
  "input_cost": 0.025,
  "output_cost": 0.075,
  "cache_hit_input_cost": 0.0,
  "cache_creation_input_cost": 0.0,
  "max_context_window": 8192,
  "streaming_support": 1,
  "function_call": 1,
  "image_support": 0,
  "source": "db",
  "provider": {
    "id": "my-custom-provider",
    "provider_id": "my-custom-provider",
    "provider_name": "My Custom Provider",
    "organization_id": 123
  }
}
Create a new custom model or update an existing one (upsert by model_name). Custom models allow you to define organization-specific configurations with custom pricing, capabilities, and provider associations.
Upsert behavior: If a model with the same model_name already exists in your organization, it will be updated with the new values.

Request body

model_name
string
required
Unique model name within your organization. This will be used to reference the model in API calls.
"model_name": "my-custom-gpt-4"
base_model_name
string
Base model to inherit properties from. Can be a global model (e.g., "gpt-4") or another custom model.
"base_model_name": "gpt-4"
display_name
string
Human-readable display name for the model.
"display_name": "My Custom GPT-4"
custom_provider_id
integer | string
ID or provider_id of the custom provider to associate with this model. See Custom Providers.
"custom_provider_id": "my-azure-provider"
provider_id
integer | string
Alternative to custom_provider_id. Either one can be used.

Pricing

input_cost
float
Cost per 1M input tokens in USD.
"input_cost": 0.025
output_cost
float
Cost per 1M output tokens in USD.
"output_cost": 0.075
cache_hit_input_cost
float
Cost per 1M cached input tokens in USD.
cache_creation_input_cost
float
Cost per 1M cache creation tokens in USD.

Capabilities

max_context_window
integer
Maximum context window size for the model.
"max_context_window": 8192
streaming_support
integer
Streaming support. 0 for no, 1 for yes.
function_call
integer
Function calling support. 0 for no, 1 for yes.
image_support
integer
Image/vision support. 0 for no, 1 for yes.
supported_params_override
object
Override UI parameter support for this model in the Playground. See the model detail endpoint for current values.
{
  "supported_params_override": {
    "temperature": {
      "name": "temperature",
      "type": "number",
      "default": 0.7,
      "min": 0,
      "max": 1.5
    }
  }
}

Response

Returns the created or updated model object.
{
  "id": "my-custom-gpt-4",
  "model_name": "my-custom-gpt-4",
  "display_name": "My Custom GPT-4",
  "base_model_name": "gpt-4",
  "affiliation_category": "custom",
  "is_called_by_custom_name": false,
  "input_cost": 0.025,
  "output_cost": 0.075,
  "cache_hit_input_cost": 0.0,
  "cache_creation_input_cost": 0.0,
  "max_context_window": 8192,
  "streaming_support": 1,
  "function_call": 1,
  "image_support": 0,
  "source": "db",
  "provider": {
    "id": "my-custom-provider",
    "provider_id": "my-custom-provider",
    "provider_name": "My Custom Provider",
    "organization_id": 123
  }
}
import requests

url = "https://api.keywordsai.co/api/models/"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
payload = {
    "model_name": "my-custom-gpt-4",
    "base_model_name": "gpt-4",
    "display_name": "My Custom GPT-4",
    "custom_provider_id": "my-azure-provider",
    "input_cost": 0.025,
    "output_cost": 0.075
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())