curl --request POST \
--url https://inference.api.nscale.com/anthropic/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"max_tokens": 2,
"messages": [
{
"role": "user",
"content": "<string>"
}
],
"system": "<string>",
"stop_sequences": [
"<string>"
],
"stream": false,
"temperature": 123,
"top_p": 123,
"tools": [
{
"name": "<string>",
"input_schema": {},
"description": "<string>",
"type": "custom"
}
],
"tool_choice": {
"type": "auto"
}
}
'import requests
url = "https://inference.api.nscale.com/anthropic/v1/messages"
payload = {
"model": "<string>",
"max_tokens": 2,
"messages": [
{
"role": "user",
"content": "<string>"
}
],
"system": "<string>",
"stop_sequences": ["<string>"],
"stream": False,
"temperature": 123,
"top_p": 123,
"tools": [
{
"name": "<string>",
"input_schema": {},
"description": "<string>",
"type": "custom"
}
],
"tool_choice": { "type": "auto" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
max_tokens: 2,
messages: [{role: 'user', content: '<string>'}],
system: '<string>',
stop_sequences: ['<string>'],
stream: false,
temperature: 123,
top_p: 123,
tools: [{name: '<string>', input_schema: {}, description: '<string>', type: 'custom'}],
tool_choice: {type: 'auto'}
})
};
fetch('https://inference.api.nscale.com/anthropic/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://inference.api.nscale.com/anthropic/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'max_tokens' => 2,
'messages' => [
[
'role' => 'user',
'content' => '<string>'
]
],
'system' => '<string>',
'stop_sequences' => [
'<string>'
],
'stream' => false,
'temperature' => 123,
'top_p' => 123,
'tools' => [
[
'name' => '<string>',
'input_schema' => [
],
'description' => '<string>',
'type' => 'custom'
]
],
'tool_choice' => [
'type' => 'auto'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://inference.api.nscale.com/anthropic/v1/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"max_tokens\": 2,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"input_schema\": {},\n \"description\": \"<string>\",\n \"type\": \"custom\"\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://inference.api.nscale.com/anthropic/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"max_tokens\": 2,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"input_schema\": {},\n \"description\": \"<string>\",\n \"type\": \"custom\"\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://inference.api.nscale.com/anthropic/v1/messages")
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 \"model\": \"<string>\",\n \"max_tokens\": 2,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"input_schema\": {},\n \"description\": \"<string>\",\n \"type\": \"custom\"\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "<string>"
}
],
"model": "<string>",
"stop_reason": "end_turn",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Create an Anthropic-format message
Creates a message using Anthropic-compatible request and response formats. Supports text, model-dependent image inputs and custom function tools. Native Anthropic caching, hosted tools and token-count endpoints are unavailable. Errors may use the OpenAI or Anthropic error format. Streaming uses named events and ends with message_stop, without a [DONE] marker. Authenticate with a Nscale bearer token in Authorization. Native x-api-key authentication is not supported; anthropic-version and anthropic-beta headers do not enable additional features.
curl --request POST \
--url https://inference.api.nscale.com/anthropic/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"max_tokens": 2,
"messages": [
{
"role": "user",
"content": "<string>"
}
],
"system": "<string>",
"stop_sequences": [
"<string>"
],
"stream": false,
"temperature": 123,
"top_p": 123,
"tools": [
{
"name": "<string>",
"input_schema": {},
"description": "<string>",
"type": "custom"
}
],
"tool_choice": {
"type": "auto"
}
}
'import requests
url = "https://inference.api.nscale.com/anthropic/v1/messages"
payload = {
"model": "<string>",
"max_tokens": 2,
"messages": [
{
"role": "user",
"content": "<string>"
}
],
"system": "<string>",
"stop_sequences": ["<string>"],
"stream": False,
"temperature": 123,
"top_p": 123,
"tools": [
{
"name": "<string>",
"input_schema": {},
"description": "<string>",
"type": "custom"
}
],
"tool_choice": { "type": "auto" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
max_tokens: 2,
messages: [{role: 'user', content: '<string>'}],
system: '<string>',
stop_sequences: ['<string>'],
stream: false,
temperature: 123,
top_p: 123,
tools: [{name: '<string>', input_schema: {}, description: '<string>', type: 'custom'}],
tool_choice: {type: 'auto'}
})
};
fetch('https://inference.api.nscale.com/anthropic/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://inference.api.nscale.com/anthropic/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'max_tokens' => 2,
'messages' => [
[
'role' => 'user',
'content' => '<string>'
]
],
'system' => '<string>',
'stop_sequences' => [
'<string>'
],
'stream' => false,
'temperature' => 123,
'top_p' => 123,
'tools' => [
[
'name' => '<string>',
'input_schema' => [
],
'description' => '<string>',
'type' => 'custom'
]
],
'tool_choice' => [
'type' => 'auto'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://inference.api.nscale.com/anthropic/v1/messages"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"max_tokens\": 2,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"input_schema\": {},\n \"description\": \"<string>\",\n \"type\": \"custom\"\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\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(string(body))
}HttpResponse<String> response = Unirest.post("https://inference.api.nscale.com/anthropic/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"max_tokens\": 2,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"input_schema\": {},\n \"description\": \"<string>\",\n \"type\": \"custom\"\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://inference.api.nscale.com/anthropic/v1/messages")
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 \"model\": \"<string>\",\n \"max_tokens\": 2,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"temperature\": 123,\n \"top_p\": 123,\n \"tools\": [\n {\n \"name\": \"<string>\",\n \"input_schema\": {},\n \"description\": \"<string>\",\n \"type\": \"custom\"\n }\n ],\n \"tool_choice\": {\n \"type\": \"auto\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "<string>"
}
],
"model": "<string>",
"stop_reason": "end_turn",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Authorizations
Headers
Selects the caller's public-cloud organization. Required when the caller belongs to multiple public-cloud organizations and the URL does not select an organization; omission then returns 400. With one public-cloud organization, omission selects it automatically. An explicitly supplied value, including an empty value, that is not one of the caller's public-cloud organizations returns 403. On /organizations/{organization_id}/endpoints, the path organization_id takes precedence over this header.
1Body
Supported Messages request fields. Tool results support text only; is_error and non-text results do not affect the response. Only custom function tools are supported; disable_parallel_tool_use does not control parallel tool calls. Cache controls, metadata, top_k, hosted tools, thinking controls and reasoning-history blocks are not supported. Unknown fields may be accepted and ignored.
Response
Successful response as JSON, or server-sent events when streaming is supported and requested.
Was this page helpful?