> This page is for version v4.0.
> For other versions, use one of these documentation indexes:
> - v5.0 (default): https://humanloop.com/docs/v5/llms.txt
> - v4.0: https://humanloop.com/docs/v4/llms.txt

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

# Serialize

POST https://api.humanloop.com/v4/model-configs/serialize
Content-Type: application/json

Serialize a model config to a .prompt file format.

Reference: https://humanloop.com/docs/v4/api/model-configs/serialize

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Body (application/json)

This endpoint expects a ModelConfigsSerializeRequest.

- `ModelConfigsSerializeRequest`

## Response

### 200

Successful Response

- `string`

## Errors

### 422 Model Configs Serialize Request Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ModelConfigChatRequest

Chat model config request.

- `model` (string, required) — The model instance used. E.g. text-davinci-002.
- `name` (string, optional) — A friendly display name for the model config. If not provided, a name will be generated.
- `description` (string, optional) — A description of the model config.
- `provider` (enum, optional) — The company providing the underlying model service.
  - Allowed values: `anthropic`, `bedrock`, `cohere`, `deepseek`, `google`, `groq`, `mock`, `openai`, `openai_azure`, `replicate`
- `max_tokens` (integer, optional, default: -1) — The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt
- `temperature` (double, optional, default: 1) — What sampling temperature to use when making a generation. Higher values means the model will be more creative.
- `top_p` (double, optional, default: 1) — An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
- `stop` (ModelConfigChatRequestStop, optional) — The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.
- `presence_penalty` (double, optional, default: 0) — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.
- `frequency_penalty` (double, optional, default: 0) — Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.
- `other` (map from string to any, optional) — Other parameter values to be passed to the provider call.
- `seed` (integer, optional) — If specified, model will make a best effort to sample deterministically, but it is not guaranteed.
- `response_format` (ResponseFormat, optional) — The format of the response. Only type json_object is currently supported for chat.
- `reasoning_effort` (ModelConfigChatRequestReasoningEffort, optional) — Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.
- `template_language` (enum, optional) — The template language to use for rendering the template.
  - Allowed values: `default`, `jinja`
- `endpoint` (enum, optional) — The provider model endpoint used.
  - Allowed values: `complete`, `chat`, `edit`
- `chat_template` (list of ChatMessageWithToolCall, optional) — Messages prepended to the list of messages sent to the provider. These messages that will take your specified inputs to form your final request to the provider model. Input variables within the template should be specified with syntax: `{{input_name}}`.
- `tools` (list of ModelConfigChatRequestToolsItem, optional) — Make tools available to OpenAIs chat model as functions.

### ModelConfigCompletionRequest

Completion model config request

- `model` (string, required) — The model instance used. E.g. text-davinci-002.
- `name` (string, optional) — A friendly display name for the model config. If not provided, a name will be generated.
- `description` (string, optional) — A description of the model config.
- `provider` (enum, optional) — The company providing the underlying model service.
  - Allowed values: `anthropic`, `bedrock`, `cohere`, `deepseek`, `google`, `groq`, `mock`, `openai`, `openai_azure`, `replicate`
- `max_tokens` (integer, optional, default: -1) — The maximum number of tokens to generate. Provide max_tokens=-1 to dynamically calculate the maximum number of tokens to generate given the length of the prompt
- `temperature` (double, optional, default: 1) — What sampling temperature to use when making a generation. Higher values means the model will be more creative.
- `top_p` (double, optional, default: 1) — An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.
- `stop` (ModelConfigCompletionRequestStop, optional) — The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.
- `presence_penalty` (double, optional, default: 0) — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the generation so far.
- `frequency_penalty` (double, optional, default: 0) — Number between -2.0 and 2.0. Positive values penalize new tokens based on how frequently they appear in the generation so far.
- `other` (map from string to any, optional) — Other parameter values to be passed to the provider call.
- `seed` (integer, optional) — If specified, model will make a best effort to sample deterministically, but it is not guaranteed.
- `response_format` (ResponseFormat, optional) — The format of the response. Only type json_object is currently supported for chat.
- `reasoning_effort` (ModelConfigCompletionRequestReasoningEffort, optional) — Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.
- `template_language` (enum, optional) — The template language to use for rendering the template.
  - Allowed values: `default`, `jinja`
- `endpoint` (enum, optional) — The provider model endpoint used.
  - Allowed values: `complete`, `chat`, `edit`
- `prompt_template` (string, optional) — Prompt template that will take your specified inputs to form your final request to the model. Input variables within the prompt template should be specified with syntax: `{{input_name}}`.

### ValidationError

- `loc` (list of ValidationErrorLocItem, required)
- `msg` (string, required)
- `type` (string, required)

### ModelConfigChatRequestStop

The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.

### ResponseFormat

Response format of the model.

- `type` (enum, required)
  - Allowed values: `json_object`, `json_schema`
- `json_schema` (map from string to any, optional) — The JSON schema of the response format if type is json_schema.

### ModelConfigChatRequestReasoningEffort

Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.

### ChatMessageWithToolCall

- `role` (enum, required) — Role of the message author.
  - Allowed values: `user`, `assistant`, `system`, `tool`, `developer`
- `content` (Content, optional) — The content of the message.
- `name` (string, optional) — Optional name of the message author.
- `tool_call_id` (string, optional) — Tool call that this message is responding to.
- `tool_calls` (list of ToolCall, optional) — A list of tool calls requested by the assistant.
- `thinking` (list of ChatMessageWithToolCallThinkingItem, optional) — Model's chain-of-thought for providing the response. Present on assistant messages if model supports it.
- `tool_call` (FunctionTool, optional, deprecated) — NB: Deprecated in favour of tool_calls. A tool call requested by the assistant.

### ModelConfigChatRequestToolsItem

### ModelConfigCompletionRequestStop

The string (or list of strings) after which the model will stop generating. The returned text will not contain the stop sequence.

### ModelConfigCompletionRequestReasoningEffort

Guidance on how many reasoning tokens it should generate before creating a response to the prompt. OpenAI reasoning models (o1, o3-mini) expect a OpenAIReasoningEffort enum. Anthropic reasoning models expect an integer, which signifies the maximum token budget.

### ValidationErrorLocItem

### Content

The content of the message.

### ToolCall

A tool call to be made.

- `id` (string, required)
- `type` ("function", required) — The type of tool to call.
- `function` (FunctionTool, required) — A function tool to be called by the model where user owns runtime.

### ChatMessageWithToolCallThinkingItem

- `type`: `thinking`
  - `signature` (string, required) — Cryptographic signature that verifies the thinking block was generated by Anthropic.
  - `thinking` (string, required) — Model's chain-of-thought for providing the response.
- `type`: `redacted_thinking`
  - `data` (string, required) — Thinking block Anthropic redacted for safety reasons. User is expected to pass the block back to Anthropic

### FunctionTool

A function tool to be called by the model where user owns runtime.

- `name` (string, required)
- `arguments` (string, optional)

### LinkedToolRequest

- `id` (string, required) — The ID of the linked tool. Starts with "oc_"
- `source` ("organization", required) — The source of the linked tool. For a linked tool it should be `organization`
- `name` (string, optional) — The name of the linked tool.
- `description` (string, optional) — The description of the linked tool.
- `strict` (boolean, optional) — Whether the tool is strict or not. If strict, the model will be forced to respond with JSON matching the parameters schema.
- `parameters` (map from string to any, optional) — The parameters of the linked tool.

### ModelConfigToolRequest

Definition of tool within a model config. The subset of ToolConfig parameters received by the chat endpoint. Does not have things like the signature or setup schema.

- `name` (string, required) — The name of the tool shown to the model.
- `description` (string, optional) — The description of the tool shown to the model.
- `strict` (boolean, optional) — Whether the tool is strict or not. If strict, the model will be forced to respond with JSON matching the parameters schema.
- `parameters` (map from string to any, optional) — Definition of parameters needed to run the tool. Provided in jsonschema format: https://json-schema.org/
- `source` (enum, optional) — Source of the tool. If defined at an organization level will be 'organization' else 'inline'.
  - Allowed values: `organization`, `inline`
- `source_code` (string, optional) — Code source of the tool.
- `other` (map from string to any, optional) — Other parameters that define the config.
- `preset_name` (string, optional) — If is_preset = true, this is the name of the preset tool on Humanloop. This is used as the key to look up the Humanloop runtime of the tool

## Examples

**Request**

```json
{
  "model": "model"
}
```

**Response**

```json
"string"
```

**SDK Code**

```python
import requests

url = "https://api.humanloop.com/v4/model-configs/serialize"

payload = { "model": "model" }
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.humanloop.com/v4/model-configs/serialize';
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"model":"model"}'
};

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.humanloop.com/v4/model-configs/serialize"

	payload := strings.NewReader("{\n  \"model\": \"model\"\n}")

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

	req.Header.Add("X-API-KEY", "<apiKey>")
	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.humanloop.com/v4/model-configs/serialize")

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

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"model\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.humanloop.com/v4/model-configs/serialize")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"model\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.humanloop.com/v4/model-configs/serialize', [
  'body' => '{
  "model": "model"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.humanloop.com/v4/model-configs/serialize");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"model\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["model": "model"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v4/model-configs/serialize")! 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()
```