Create custom model

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. <Note> **Upsert behavior**: If a model with the same `model_name` already exists in your organization, it will be updated with the new values. </Note> ## Request body - `model_name` *string* **required**: Unique model name within your organization. This will be used to reference the model in API calls. **Example** ```json "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. **Example** ```json "base_model_name": "gpt-4" ``` - `display_name` *string*: Human-readable display name for the model. **Example** ```json "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](/api-reference/manage/models/custom-providers/list). **Example** ```json "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. **Example** ```json "input_cost": 0.025 ``` - `output_cost` *float*: Cost per 1M output tokens in USD. **Example** ```json "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. **Example** ```json "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. **Example** ```json { "supported_params_override": { "temperature": { "name": "temperature", "type": "number", "default": 0.7, "min": 0, "max": 1.5 } } } ``` ## Response Returns the created or updated model object. ```json 201 Created { "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 } } ``` ```json 400 Bad Request { "error": "Base model not found" } ``` ```json 401 Unauthorized { "detail": "Authentication credentials were not provided." } ``` ```python Python url = "https://api.respan.ai/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()) ``` ```typescript TypeScript const url = 'https://api.respan.ai/api/models/'; const headers = { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }; const 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 }; const response = await fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(payload) }); const data = await response.json(); console.log(data); ``` ```bash cURL curl -X POST "https://api.respan.ai/api/models/" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "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 }' ```

Authentication

AuthorizationBearer
API key authentication. Get your API key from https://platform.respan.ai/platform/api-keys

Request

This endpoint expects an object.
model_namestringRequired
Unique model name within your organization. This will be used to reference the model in API calls.
base_model_namestringOptional

Base model to inherit properties from. Can be a global model (e.g., “gpt-4”) or another custom model.

display_namestringOptional

Human-readable display name for the model.

custom_provider_idinteger or stringOptional

ID or provider_id of the custom provider to associate with this model. See Custom Providers.

provider_idinteger or stringOptional

Alternative to custom_provider_id. Either one can be used.

input_costdoubleOptional
Cost per 1M input tokens in USD.
output_costdoubleOptional
Cost per 1M output tokens in USD.
cache_hit_input_costdoubleOptional
Cost per 1M cached input tokens in USD.
cache_creation_input_costdoubleOptional
Cost per 1M cache creation tokens in USD.
max_context_windowintegerOptional
Maximum context window size for the model.
streaming_supportintegerOptional
Streaming support. 0 for no, 1 for yes.
function_callintegerOptional
Function calling support. 0 for no, 1 for yes.
image_supportintegerOptional

Image/vision support. 0 for no, 1 for yes.

supported_params_overrideobjectOptional
Override UI parameter support for this model in the Playground. See the model detail endpoint for current values.

Response

Successful response for Create custom model
supported_params_overrideobject

Errors

401
Unauthorized Error