> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/apis/models/create-or-update-custom-model/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # Create or update a custom model POST https://api.respan.ai/api/models/ Content-Type: application/json Create an organization-specific custom model. If a model with the same `model_name` already exists in your organization, it is updated and the endpoint returns `200`. Reference: https://respan.ai/docs/apis/models/create-or-update-custom-model ## Authentication - `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan\_params.credential\_override in the request body, not in this authentication field. - `Authorization` header (bearer token, required) — Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead. ## Request ### Body (application/json) This endpoint expects an object. - `model_name` (string, required) — Unique model name within your organization. - `base_model_name` (string, optional) — Base model to inherit properties from. - `custom_provider_id` (string, optional) — The custom provider to call the model through. Required unless `base_model_name` is set, in which case the base model's provider is used. - `provider_id` (string, optional) — Alternative to `custom_provider_id`. - `input_cost` (double, optional) — Cost per 1M input tokens in USD. - `output_cost` (double, optional) — Cost per 1M output tokens in USD. - `cache_hit_input_cost` (double, optional) — Cost per 1M cached input tokens in USD. - `cache_creation_input_cost` (double, optional) — Cost per 1M cache creation input tokens in USD. - `max_context_window` (integer, optional) — Maximum context window size. - `function_call` (enum, optional) - Allowed values: `0`, `1` - `image_support` (enum, optional) - Allowed values: `0`, `1` - `supported_params_override` (map from string to any, optional) — Partial override for the model's parameters: a map of parameter name to a parameter definition with the same shape as `supported_params` entries (`name`, `type`, `default`, `range` with `min` and `max`, `description`, `required`), or `null` to remove the parameter. Replaces any earlier override. The response returns the computed `supported_params`. ## Response ### 200 Updated existing model. - `id` (string, required) — Model string ID. Same value as `model_name`. - `model_name` (string, required) — Model name used in API calls. - `base_model_name` (string, optional) — Base model inherited from, when configured. - `affiliation_category` (enum, optional) — `keywordsai` for built-in models, `custom` for your organization's models. - Allowed values: `keywordsai`, `custom` - `is_called_by_custom_name` (boolean, optional) — Whether requests are sent upstream using this custom model name. - `input_cost` (double, optional) — Cost per 1M input tokens in USD. - `output_cost` (double, optional) — Cost per 1M output tokens in USD. - `cache_hit_input_cost` (double, optional) — Cost per 1M cached input tokens in USD. - `cache_creation_input_cost` (double, optional) — Cost per 1M cache creation input tokens in USD. - `max_context_window` (integer, optional) — Maximum context window size. - `function_call` (enum, optional) — Function/tool calling support. `0` = no, `1` = yes. - Allowed values: `0`, `1` - `image_support` (enum, optional) — Vision input support. `0` = no, `1` = yes. - Allowed values: `0`, `1` - `model_type` (enum, optional) — Model type. - Allowed values: `chat`, `embedding`, `audio` - `supported_params` (map from string to any, optional) — Computed parameter support after applying model-specific overrides. - `provider` (ApiModelsPostResponsesContentApplicationJsonSchemaProvider, optional) ### 201 Created model. - `id` (string, required) — Model string ID. Same value as `model_name`. - `model_name` (string, required) — Model name used in API calls. - `base_model_name` (string, optional) — Base model inherited from, when configured. - `affiliation_category` (enum, optional) — `keywordsai` for built-in models, `custom` for your organization's models. - Allowed values: `keywordsai`, `custom` - `is_called_by_custom_name` (boolean, optional) — Whether requests are sent upstream using this custom model name. - `input_cost` (double, optional) — Cost per 1M input tokens in USD. - `output_cost` (double, optional) — Cost per 1M output tokens in USD. - `cache_hit_input_cost` (double, optional) — Cost per 1M cached input tokens in USD. - `cache_creation_input_cost` (double, optional) — Cost per 1M cache creation input tokens in USD. - `max_context_window` (integer, optional) — Maximum context window size. - `function_call` (enum, optional) — Function/tool calling support. `0` = no, `1` = yes. - Allowed values: `0`, `1` - `image_support` (enum, optional) — Vision input support. `0` = no, `1` = yes. - Allowed values: `0`, `1` - `model_type` (enum, optional) — Model type. - Allowed values: `chat`, `embedding`, `audio` - `supported_params` (map from string to any, optional) — Computed parameter support after applying model-specific overrides. - `provider` (ApiModelsPostResponsesContentApplicationJsonSchemaProvider, optional) ## Errors ### 400 Bad Request Error Bad Request - `detail` (string, optional) - `error` (string, optional) ### 403 Forbidden Error The API key is missing, invalid or expired, or it doesn't have permission for this action. - `detail` (string, required) ### 404 Not Found Error Not Found - `detail` (string, optional) - `error` (string, optional) ## Types ### ApiModelsPostResponsesContentApplicationJsonSchemaProvider - `id` (string, required) — Provider string ID. Same value as `provider_id`. - `provider_id` (string, required) — Unique provider identifier within your organization. - `provider_name` (string, required) — Human-readable provider name. - `extra_kwargs` (map from string to any, optional) — Provider configuration such as `base_url` and timeout values. Secret values are not returned here. - `created_at` (datetime, optional, nullable) - `updated_at` (datetime, optional, nullable) ## Examples ### Example 1 **Request** ```json { "model_name": "my-custom-gpt-4o" } ``` **Response** ```json { "id": "my-custom-gpt-4o", "model_name": "my-custom-gpt-4o", "base_model_name": "gpt-4o", "affiliation_category": "custom", "is_called_by_custom_name": false, "input_cost": 2.5, "output_cost": 10, "cache_hit_input_cost": 0.5, "cache_creation_input_cost": 3, "max_context_window": 128000, "function_call": 1, "image_support": 1, "model_type": "chat", "supported_params": {}, "provider": { "id": "my-vllm", "provider_id": "my-vllm", "provider_name": "My vLLM Server", "extra_kwargs": { "base_url": "https://vllm.example.com/v1" }, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z" } } ``` **SDK Code** ```python import requests url = "https://api.respan.ai/api/models/" payload = { "model_name": "my-custom-gpt-4o" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.respan.ai/api/models/'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"model_name":"my-custom-gpt-4o"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/models/" payload := strings.NewReader("{\n \"model_name\": \"my-custom-gpt-4o\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/models/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"model_name\": \"my-custom-gpt-4o\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.respan.ai/api/models/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"model_name\": \"my-custom-gpt-4o\"\n}") .asString(); ``` ```php request('POST', 'https://api.respan.ai/api/models/', [ 'body' => '{ "model_name": "my-custom-gpt-4o" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.respan.ai/api/models/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"model_name\": \"my-custom-gpt-4o\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["model_name": "my-custom-gpt-4o"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/models/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Example 2 **Request** ```json { "model_name": "my-custom-gpt-4o" } ``` **Response** ```json { "id": "my-custom-gpt-4o", "model_name": "my-custom-gpt-4o", "base_model_name": "gpt-4o", "affiliation_category": "custom", "is_called_by_custom_name": false, "input_cost": 2.5, "output_cost": 10, "cache_hit_input_cost": 0.5, "cache_creation_input_cost": 3, "max_context_window": 128000, "function_call": 1, "image_support": 1, "model_type": "chat", "supported_params": {}, "provider": { "id": "my-vllm", "provider_id": "my-vllm", "provider_name": "My vLLM Server", "extra_kwargs": { "base_url": "https://vllm.example.com/v1" }, "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z" } } ``` **SDK Code** ```python import requests url = "https://api.respan.ai/api/models/" payload = { "model_name": "my-custom-gpt-4o" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.respan.ai/api/models/'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"model_name":"my-custom-gpt-4o"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/models/" payload := strings.NewReader("{\n \"model_name\": \"my-custom-gpt-4o\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/models/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"model_name\": \"my-custom-gpt-4o\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.respan.ai/api/models/") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"model_name\": \"my-custom-gpt-4o\"\n}") .asString(); ``` ```php request('POST', 'https://api.respan.ai/api/models/', [ 'body' => '{ "model_name": "my-custom-gpt-4o" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.respan.ai/api/models/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"model_name\": \"my-custom-gpt-4o\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["model_name": "my-custom-gpt-4o"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/models/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```