architecture.input_modalities lists file in /v1/models.
import base64
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.naga.ac", api_key=os.environ["NAGAAI_API_KEY"])
with open("report.pdf", "rb") as f:
pdf = base64.b64encode(f.read()).decode()
message = client.messages.create(
model="claude-haiku-4.5",
max_tokens=1024,
messages=[{
"role": "user",
"content": [
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": pdf}},
{"type": "text", "text": "Summarize this document in two sentences."},
],
}],
)
print(message.content[0].text)
import fs from "node:fs";
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.naga.ac", apiKey: process.env.NAGAAI_API_KEY });
const pdf = fs.readFileSync("report.pdf").toString("base64");
const message = await client.messages.create({
model: "claude-haiku-4.5",
max_tokens: 1024,
messages: [{
role: "user",
content: [
{ type: "document", source: { type: "base64", media_type: "application/pdf", data: pdf } },
{ type: "text", text: "Summarize this document in two sentences." },
],
}],
});
for (const block of message.content) {
if (block.type === "text") console.log(block.text);
}
Sources
source.type | Use |
|---|---|
base64 | A PDF, with media_type: "application/pdf" |
url | A link to a PDF |
text | Plain text, with media_type: "text/plain" |
content | Not supported. NagaAI drops the whole document block |
image block with a base64 or url source. One inline block can be up to 20 MiB and the whole request up to 32 MiB.