> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Sync models for a provider key

POST https://api.runtype.com/v1/provider-keys/{id}/sync-models
Content-Type: application/json

Sync and upsert model configurations for a generic-openai provider key or organization connection.

Reference: https://docs.runtype.com/api-reference/runtype-api/provider-keys/sync-models-for-a-provider-key

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Path parameters

- `id` (string, required) — Provider key or organization connection ID

### Body (application/json)

This endpoint expects an object.

- `models` (list of V1ProviderKeysIdSyncModelsPostRequestBodyContentApplicationJsonSchemaModelsItems, required)

## Response

### 200

Models synced

- `success` (boolean, required)
- `syncedCount` (double, required)

## Errors

### 400 Bad Request Error

Invalid request

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 402 Payment Required Error

Feature not available

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 403 Forbidden Error

Forbidden

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 404 Not Found Error

Not found

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

### 409 Conflict Error

Organization connection or model inventory is managed by a newer Worker

- `SyncModelsForAProviderKeyRequestConflictError`
  - SyncModelsForAProviderKeyRequestConflictError0
  - SyncModelsForAProviderKeyRequestConflictError1

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `code` (string, optional) — Stable error code. `insufficient_scope` marks an API key that lacks a scope this request needs.
- `details` (list of ErrorDetailsItems, optional)
- `requiredScopes` (list of string, optional) — On `insufficient_scope`: every API key scope this request needs.

## Types

### V1ProviderKeysIdSyncModelsPostRequestBodyContentApplicationJsonSchemaModelsItems

- `id` (string, required)
- `displayName` (string, optional)
- `inputCostPer1kTokens` (double, optional)
- `maxOutputTokens` (integer, optional)
- `midConversationSystemMessages` (enum, optional) — Where a system message that follows a conversation turn lands on this endpoint. Omitted keeps it at its position (Mistral- and Gemma-family ids fold it into the leading prompt); "hoist" folds it for any endpoint whose chat template rejects a non-leading system role.
  - Allowed values: `preserve`, `hoist`
- `outputCostPer1kTokens` (double, optional)
- `reasoning` (V1ProviderKeysIdSyncModelsPostRequestBodyContentApplicationJsonSchemaModelsItemsReasoning, optional)
- `supportedResponseFormats` (list of string, optional)
- `supportsStreaming` (boolean, optional)

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### SyncModelsForAProviderKeyRequestConflictError0

- `code` (enum, required)
  - Allowed values: `ORGANIZATION_CONNECTION_MIGRATED`
- `error` (string, required)
- `replacementId` (string, required)

### SyncModelsForAProviderKeyRequestConflictError1

- `code` (enum, required)
  - Allowed values: `ORGANIZATION_MODEL_CONFIG_MIGRATED`
- `configId` (string, required)
- `details` (string, required)
- `error` (string, required)

### V1ProviderKeysIdSyncModelsPostRequestBodyContentApplicationJsonSchemaModelsItemsReasoning

- `supported` (boolean, required)
- `defaultEffort` (string, optional)

## Examples

**Request**

```json
{
  "models": [
    {
      "id": "llama-3.1-70b",
      "displayName": "Llama 3.1 70B",
      "inputCostPer1kTokens": 0.0008,
      "maxOutputTokens": 4096,
      "outputCostPer1kTokens": 0.0008,
      "supportedResponseFormats": [
        "text",
        "JSON"
      ],
      "supportsStreaming": true
    }
  ]
}
```

**Response**

```json
{
  "success": true,
  "syncedCount": 1.1
}
```

**SDK Code**

```python Sync Models
import requests

url = "https://api.runtype.com/v1/provider-keys/id/sync-models"

payload = { "models": [
        {
            "id": "llama-3.1-70b",
            "displayName": "Llama 3.1 70B",
            "inputCostPer1kTokens": 0.0008,
            "maxOutputTokens": 4096,
            "outputCostPer1kTokens": 0.0008,
            "supportedResponseFormats": ["text", "JSON"],
            "supportsStreaming": True
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Sync Models
const url = 'https://api.runtype.com/v1/provider-keys/id/sync-models';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"models":[{"id":"llama-3.1-70b","displayName":"Llama 3.1 70B","inputCostPer1kTokens":0.0008,"maxOutputTokens":4096,"outputCostPer1kTokens":0.0008,"supportedResponseFormats":["text","JSON"],"supportsStreaming":true}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Sync Models
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/provider-keys/id/sync-models"

	payload := strings.NewReader("{\n  \"models\": [\n    {\n      \"id\": \"llama-3.1-70b\",\n      \"displayName\": \"Llama 3.1 70B\",\n      \"inputCostPer1kTokens\": 0.0008,\n      \"maxOutputTokens\": 4096,\n      \"outputCostPer1kTokens\": 0.0008,\n      \"supportedResponseFormats\": [\n        \"text\",\n        \"JSON\"\n      ],\n      \"supportsStreaming\": true\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	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 Sync Models
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/provider-keys/id/sync-models")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"models\": [\n    {\n      \"id\": \"llama-3.1-70b\",\n      \"displayName\": \"Llama 3.1 70B\",\n      \"inputCostPer1kTokens\": 0.0008,\n      \"maxOutputTokens\": 4096,\n      \"outputCostPer1kTokens\": 0.0008,\n      \"supportedResponseFormats\": [\n        \"text\",\n        \"JSON\"\n      ],\n      \"supportsStreaming\": true\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Sync Models
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/provider-keys/id/sync-models")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"models\": [\n    {\n      \"id\": \"llama-3.1-70b\",\n      \"displayName\": \"Llama 3.1 70B\",\n      \"inputCostPer1kTokens\": 0.0008,\n      \"maxOutputTokens\": 4096,\n      \"outputCostPer1kTokens\": 0.0008,\n      \"supportedResponseFormats\": [\n        \"text\",\n        \"JSON\"\n      ],\n      \"supportsStreaming\": true\n    }\n  ]\n}")
  .asString();
```

```php Sync Models
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/provider-keys/id/sync-models', [
  'body' => '{
  "models": [
    {
      "id": "llama-3.1-70b",
      "displayName": "Llama 3.1 70B",
      "inputCostPer1kTokens": 0.0008,
      "maxOutputTokens": 4096,
      "outputCostPer1kTokens": 0.0008,
      "supportedResponseFormats": [
        "text",
        "JSON"
      ],
      "supportsStreaming": true
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Sync Models
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/provider-keys/id/sync-models");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"models\": [\n    {\n      \"id\": \"llama-3.1-70b\",\n      \"displayName\": \"Llama 3.1 70B\",\n      \"inputCostPer1kTokens\": 0.0008,\n      \"maxOutputTokens\": 4096,\n      \"outputCostPer1kTokens\": 0.0008,\n      \"supportedResponseFormats\": [\n        \"text\",\n        \"JSON\"\n      ],\n      \"supportsStreaming\": true\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Sync Models
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["models": [
    [
      "id": "llama-3.1-70b",
      "displayName": "Llama 3.1 70B",
      "inputCostPer1kTokens": 0.0008,
      "maxOutputTokens": 4096,
      "outputCostPer1kTokens": 0.0008,
      "supportedResponseFormats": ["text", "JSON"],
      "supportsStreaming": true
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/provider-keys/id/sync-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()
```