HomeTrang chủ · IntegrationsTích hợp · Vercel AI SDKVercel AI SDK
Idemcore for the Vercel AI SDKIdemcore cho Vercel AI SDK
Use Idemcore with the Vercel AI SDK. The signed receipt is on the response metadata.Dùng Idemcore với Vercel AI SDK. Biên nhận có chữ ký nằm trong metadata của câu trả lời.
The Idemcore provider for the Vercel AI SDK lets you call Idemcore with generateText or streamText. The signed receipt is returned on providerMetadata.idemcore.Provider Idemcore cho Vercel AI SDK cho phép gọi Idemcore bằng generateText hoặc streamText. Biên nhận có chữ ký nằm trong providerMetadata.idemcore.
Install stepsCác bước cài đặt
- 1Install Node.js 18 or newer, and the ai package v7.Cài Node.js 18 trở lên, và gói ai bản 7.
- 2Run npm i ai @idemcore/ai-sdk-provider.Chạy npm i ai @idemcore/ai-sdk-provider.
- 3Export IDEMCORE_API_KEY and call generateText or streamText with createIdemcore().Xuất IDEMCORE_API_KEY và gọi generateText hoặc streamText với createIdemcore().
- 4Read providerMetadata.idemcore for the receipt, and optionally re-check it with verifyReceipt.Đọc providerMetadata.idemcore để lấy biên nhận, và có thể kiểm lại bằng verifyReceipt.
PrerequisitesĐiều kiện cần
- Node.js 18 or newer.
- The
aipackage v7 (this provider implements the current Language Model v4 interface). - An Idemcore API key in
IDEMCORE_API_KEY, or passed tocreateIdemcore({ apiKey }).
- Node.js 18 trở lên.
- Gói
aibản 7 (provider này triển khai giao diện Language Model v4 hiện tại). - Khóa API Idemcore trong
IDEMCORE_API_KEY, hoặc truyền vàocreateIdemcore({ apiKey }).
A minimal working exampleVí dụ tối thiểu chạy được
A minimal generateText call that prints the receipt id:Một lời gọi generateText tối thiểu, in mã biên nhận:
import { generateText } from "ai";
import { createIdemcore } from "@idemcore/ai-sdk-provider";
const idemcore = createIdemcore(); // reads IDEMCORE_API_KEY
const { text, providerMetadata } = await generateText({
model: idemcore("qwen3.8-27b-idna"),
prompt: "Name the three primary colours.",
maxOutputTokens: 64,
});
console.log(text);
console.log(providerMetadata?.idemcore?.receiptId);
console.log(providerMetadata?.idemcore?.receipt);Streaming yields text as it arrives. The receipt is on the final finish part, via providerMetadata.idemcore. You can re-check a receipt with verifyReceipt from @idemcore/sdk. Optional privacy: providerOptions: { idemcore: { privacy: "hash_only" } }.Streaming trả dần văn bản. Biên nhận nằm ở phần kết thúc, qua providerMetadata.idemcore. Bạn có thể kiểm lại biên nhận bằng verifyReceipt từ @idemcore/sdk. Privacy tùy chọn: providerOptions: { idemcore: { privacy: "hash_only" } }.
Options and configurationTùy chọn và cấu hình
- Decoding is greedy: temperature is fixed at 0. A non-zero temperature throws before a request is made. Other sampling settings and tool calling produce warnings, or an error if a tool is required.
maxOutputTokensis forwarded asmaxTokens(1–2048).- Embeddings, image, and speech models are not available.
- Giải mã là greedy: temperature được cố định ở 0. Temperature khác 0 sẽ báo lỗi trước khi gửi yêu cầu. Các thiết lập lấy mẫu khác và gọi công cụ sẽ cảnh báo, hoặc báo lỗi nếu bắt buộc phải dùng công cụ.
maxOutputTokensđược chuyển thànhmaxTokens(1–2048).- Không có mô hình embeddings, ảnh hay giọng nói.
TroubleshootingXử lý sự cố
Cannot find module @idemcore/ai-sdk-provider or ai.Không tìm thấy module @idemcore/ai-sdk-provider hoặc ai.
Install both packages: npm i ai @idemcore/ai-sdk-provider. This provider targets ai v7.Hãy cài cả hai gói: npm i ai @idemcore/ai-sdk-provider. Provider này dành cho ai bản 7.
The receipt is missing on stream chunks.Biên nhận không có trên từng chunk stream.
Read providerMetadata.idemcore on the final finish part, after the answer is complete.Hãy đọc providerMetadata.idemcore ở phần kết thúc, sau khi câu trả lời hoàn tất.
Version and changelogPhiên bản và nhật ký thay đổi
Current published version: 0.1.0.Phiên bản đang phát hành: 0.1.0.
See the version on npm, and the site changelog.Xem phiên bản trên npm, và nhật ký thay đổi trên site.
SupportHỗ trợ
Questions about install, API keys or receipts: support@idemcore.net. Security reports: security@idemcore.net. Sales and pilots: dev@idemcore.net.Câu hỏi về cài đặt, khóa API hoặc biên nhận: support@idemcore.net. Báo cáo bảo mật: security@idemcore.net. Bán hàng và thí điểm: dev@idemcore.net.
support@idemcore.net · Contact page →Trang liên hệ →
Package registryKho gói
How to get an API keyCách lấy khóa API
createIdemcore() reads IDEMCORE_API_KEY, or you can pass { apiKey }. verifyReceipt from @idemcore/sdk checks a saved receipt locally.createIdemcore() đọc IDEMCORE_API_KEY, hoặc bạn có thể truyền { apiKey }. verifyReceipt từ @idemcore/sdk kiểm biên nhận đã lưu ngay trên máy.
To create a key, sign in to the console and create an API key. It starts with ick_ and is shown once, so keep it on your server. Then set IDEMCORE_API_KEY in the environment.Để tạo khóa, đăng nhập console và tạo khóa API. Khóa bắt đầu bằng ick_ và chỉ hiện một lần, hãy giữ nó ở phía máy chủ. Sau đó đặt IDEMCORE_API_KEY trong biến môi trường.
Get a key on this site →Lấy khóa trên trang này → Open the console →Mở console →
How to check a receiptCách kiểm biên nhận
The signed receipt is on providerMetadata.idemcore. You can re-check it with verifyReceipt from @idemcore/sdk, or open a public share on the receipt page at idemcore.net/r/.Biên nhận có chữ ký nằm trên providerMetadata.idemcore. Bạn có thể kiểm lại bằng verifyReceipt từ @idemcore/sdk, hoặc mở bản chia sẻ công khai trên trang biên nhận tại idemcore.net/r/.
You can also open a public share on the receipt page, or use the check page on this site.Bạn cũng có thể mở bản chia sẻ công khai trên trang biên nhận, hoặc dùng trang kiểm trên site này.
Receipt page →Trang biên nhận → Check a receipt →Kiểm một biên nhận →