Skip to content

Claude Fable 5.2 ​

本页说明本站网关实际支持的调用方式。价格以模型详情页为准:https://modelfold.ai/models/claude-fable-5-2

接口 ​

POST /chat/completions

完整 URL: https://modelfold.ai/v1/chat/completions

鉴权:所有请求都需要 Authorization: Bearer <API_KEY> 请求头。

本站将此请求转换为模型上游协议,返回 OpenAI 风格的对话结果。stream: true 时以 SSE 返回。编程智能体及原生协议接入见 AI Agent,模型 ID 同样是 claude-fable-5-2。

请求参数 ​

请求体 (application/json) ​

参数类型必填说明
modelstring是可选值:claude-fable-5-2。 示例:claude-fable-5-2。
messagesarray&lt;object&gt;是minItems: 1.
  messages[].rolestring是可选值:system / user / assistant。 示例:user。
  messages[].contentstring | array&lt;object&gt;是字符串,或内容数组:{"type":"text","text":"..."} 与 {"type":"image_url","image_url":{"url":"data:image/png;base64,..."}}。支持图片输入:image_url 请用 data:image base64 地址(png / jpeg / webp / gif),建议单张不超过 5MB、单次请求最多 10 张(与网页对话一致);http(s) 图片链接只会原样转发,不保证每个模型都能读取。
max_tokensinteger否默认值:1024。 示例:1024。
temperaturenumber否—

请求示例 ​

bash
curl -X POST "https://modelfold.ai/v1/chat/completions" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-fable-5-2",
  "messages": [
    {
      "role": "user",
      "content": "In one sentence, what does a tide table tell a sailor?"
    }
  ],
  "max_tokens": 80
}'
python
import os
from openai import OpenAI

client = OpenAI(base_url="https://modelfold.ai/v1", api_key=os.environ["MODELFOLD_API_KEY"])

resp = client.chat.completions.create(
    model="claude-fable-5-2",
    messages=[
        {
            "role": "user",
            "content": "In one sentence, what does a tide table tell a sailor?",
        },
    ],
)
print(resp.choices[0].message.content)
javascript
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://modelfold.ai/v1", apiKey: process.env.MODELFOLD_API_KEY });

const resp = await client.chat.completions.create({
  model: "claude-fable-5-2",
  messages: [{"role":"user","content":"In one sentence, what does a tide table tell a sailor?"}],
});
console.log(resp.choices[0].message.content);
python
import os
import requests

resp = requests.post(
    "https://modelfold.ai/v1/chat/completions",
    headers={
        "Authorization": "Bearer " + os.environ["MODELFOLD_API_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "claude-fable-5-2",
        "messages": [
            {
                "role": "user",
                "content": "In one sentence, what does a tide table tell a sailor?",
            },
        ],
        "max_tokens": 80,
    },
)
print(resp.json())
javascript
const resp = await fetch("https://modelfold.ai/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.MODELFOLD_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "claude-fable-5-2",
    "messages": [
      {
        "role": "user",
        "content": "In one sentence, what does a tide table tell a sailor?"
      }
    ],
    "max_tokens": 80
  }),
});
console.log(await resp.json());
go
package main

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

func main() {
	body := strings.NewReader(`{"model":"claude-fable-5-2","messages":[{"role":"user","content":"In one sentence, what does a tide table tell a sailor?"}],"max_tokens":80}`)
	req, _ := http.NewRequest("POST", "https://modelfold.ai/v1/chat/completions", body)
	req.Header.Set("Authorization", "Bearer " + os.Getenv("MODELFOLD_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	out, _ := io.ReadAll(resp.Body)
	fmt.Println(string(out))
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String body = "{\"model\":\"claude-fable-5-2\",\"messages\":[{\"role\":\"user\",\"content\":\"In one sentence, what does a tide table tell a sailor?\"}],\"max_tokens\":80}";
        HttpRequest req = HttpRequest.newBuilder()
            .uri(URI.create("https://modelfold.ai/v1/chat/completions"))
            .header("Authorization", "Bearer " + System.getenv("MODELFOLD_API_KEY"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .build();
        HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println(resp.body());
    }
}
php
<?php
$ch = curl_init('https://modelfold.ai/v1/chat/completions');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv("MODELFOLD_API_KEY"),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{"model":"claude-fable-5-2","messages":[{"role":"user","content":"In one sentence, what does a tide table tell a sailor?"}],"max_tokens":80}',
]);
echo curl_exec($ch);
curl_close($ch);
csharp
using System;
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://modelfold.ai/v1/chat/completions");
req.Headers.TryAddWithoutValidation("Authorization", "Bearer " + Environment.GetEnvironmentVariable("MODELFOLD_API_KEY"));
req.Content = new StringContent("{\"model\":\"claude-fable-5-2\",\"messages\":[{\"role\":\"user\",\"content\":\"In one sentence, what does a tide table tell a sailor?\"}],\"max_tokens\":80}", Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());
json
{
  "model": "claude-fable-5-2",
  "messages": [
    {
      "role": "user",
      "content": "In one sentence, what does a tide table tell a sailor?"
    }
  ],
  "max_tokens": 80
}

图片输入示例 ​

图片放在 content 数组里,用 data URL 传入。把 BASE64_IMAGE_DATA 换成图片文件的 base64。

bash
curl -X POST "https://modelfold.ai/v1/chat/completions" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-fable-5-2",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "用一句话描述这张图。"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "data:image/png;base64,<BASE64_IMAGE_DATA>"
          }
        }
      ]
    }
  ],
  "max_tokens": 512
}'
python
import os
from openai import OpenAI

client = OpenAI(base_url="https://modelfold.ai/v1", api_key=os.environ["MODELFOLD_API_KEY"])

resp = client.chat.completions.create(
    model="claude-fable-5-2",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "用一句话描述这张图。",
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "data:image/png;base64,<BASE64_IMAGE_DATA>",
                    },
                },
            ],
        },
    ],
)
print(resp.choices[0].message.content)
javascript
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://modelfold.ai/v1", apiKey: process.env.MODELFOLD_API_KEY });

const resp = await client.chat.completions.create({
  model: "claude-fable-5-2",
  messages: [{"role":"user","content":[{"type":"text","text":"用一句话描述这张图。"},{"type":"image_url","image_url":{"url":"data:image/png;base64,<BASE64_IMAGE_DATA>"}}]}],
});
console.log(resp.choices[0].message.content);
python
import os
import requests

resp = requests.post(
    "https://modelfold.ai/v1/chat/completions",
    headers={
        "Authorization": "Bearer " + os.environ["MODELFOLD_API_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "claude-fable-5-2",
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "用一句话描述这张图。",
                    },
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": "data:image/png;base64,<BASE64_IMAGE_DATA>",
                        },
                    },
                ],
            },
        ],
        "max_tokens": 512,
    },
)
print(resp.json())
javascript
const resp = await fetch("https://modelfold.ai/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.MODELFOLD_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "claude-fable-5-2",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "用一句话描述这张图。"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "data:image/png;base64,<BASE64_IMAGE_DATA>"
            }
          }
        ]
      }
    ],
    "max_tokens": 512
  }),
});
console.log(await resp.json());
go
package main

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

func main() {
	body := strings.NewReader(`{"model":"claude-fable-5-2","messages":[{"role":"user","content":[{"type":"text","text":"用一句话描述这张图。"},{"type":"image_url","image_url":{"url":"data:image/png;base64,<BASE64_IMAGE_DATA>"}}]}],"max_tokens":512}`)
	req, _ := http.NewRequest("POST", "https://modelfold.ai/v1/chat/completions", body)
	req.Header.Set("Authorization", "Bearer " + os.Getenv("MODELFOLD_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	out, _ := io.ReadAll(resp.Body)
	fmt.Println(string(out))
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String body = "{\"model\":\"claude-fable-5-2\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"用一句话描述这张图。\"},{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/png;base64,<BASE64_IMAGE_DATA>\"}}]}],\"max_tokens\":512}";
        HttpRequest req = HttpRequest.newBuilder()
            .uri(URI.create("https://modelfold.ai/v1/chat/completions"))
            .header("Authorization", "Bearer " + System.getenv("MODELFOLD_API_KEY"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .build();
        HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println(resp.body());
    }
}
php
<?php
$ch = curl_init('https://modelfold.ai/v1/chat/completions');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv("MODELFOLD_API_KEY"),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{"model":"claude-fable-5-2","messages":[{"role":"user","content":[{"type":"text","text":"用一句话描述这张图。"},{"type":"image_url","image_url":{"url":"data:image/png;base64,<BASE64_IMAGE_DATA>"}}]}],"max_tokens":512}',
]);
echo curl_exec($ch);
curl_close($ch);
csharp
using System;
using System.Net.Http;
using System.Text;

var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://modelfold.ai/v1/chat/completions");
req.Headers.TryAddWithoutValidation("Authorization", "Bearer " + Environment.GetEnvironmentVariable("MODELFOLD_API_KEY"));
req.Content = new StringContent("{\"model\":\"claude-fable-5-2\",\"messages\":[{\"role\":\"user\",\"content\":[{\"type\":\"text\",\"text\":\"用一句话描述这张图。\"},{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/png;base64,<BASE64_IMAGE_DATA>\"}}]}],\"max_tokens\":512}", Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());

响应 ​

200 — 对话完成;usage 返回请求用量。 ​

json
{
  "ok": true,
  "object": "chat.completion",
  "model": "claude-fable-5-2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A tide table tells a sailor the predicted times and heights of high and low tides at a given location, so they can know when the water will be deep enough to navigate safely."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {}
}

ModelFold — 一个 API,接入所有主流 AI 模型。