← 返回 Skills 市场
Ainative React Sdk
作者
Toby Morning
· GitHub ↗
· v1.0.0
· MIT-0
139
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install ainative-react-sdk
功能描述
Use @ainative/react-sdk to add AI chat and credits to React apps. Use when (1) Installing @ainative/react-sdk, (2) Using the useChat hook for chat completion...
使用说明 (SKILL.md)
@ainative/react-sdk
React hooks and components for AINative — chat completions, credit tracking, and managed sessions.
Install
npm install @ainative/react-sdk
Setup: AINativeProvider
Wrap your app (or a subtree) with the provider:
import { AINativeProvider } from '@ainative/react-sdk';
function App() {
return (
\x3CAINativeProvider config={{ apiKey: 'ak_your_key' }}>
\x3CYourApp />
\x3C/AINativeProvider>
);
}
useChat Hook
import { useChat } from '@ainative/react-sdk';
import type { Message } from '@ainative/react-sdk';
function ChatUI() {
const { messages, isLoading, error, sendMessage } = useChat({
model: 'claude-3-5-sonnet-20241022',
temperature: 0.7,
max_tokens: 1024,
});
const handleSend = async (input: string) => {
await sendMessage([
...messages,
{ role: 'user', content: input }
]);
};
return (
\x3Cdiv>
{messages.map((msg, i) => (
\x3Cdiv key={i} className={`message ${msg.role}`}>
\x3Cstrong>{msg.role}:\x3C/strong> {msg.content}
\x3C/div>
))}
{isLoading && \x3Cdiv>Thinking...\x3C/div>}
{error && \x3Cdiv className="error">Error: {error.message}\x3C/div>}
\x3Cinput
onKeyDown={(e) => e.key === 'Enter' && handleSend(e.currentTarget.value)}
placeholder="Type a message..."
/>
\x3C/div>
);
}
useChat Options
| Option | Type | Default | Description |
|---|---|---|---|
model |
string | — | Model ID (e.g. claude-3-5-sonnet-20241022) |
temperature |
number | 0.7 | Randomness (0–1) |
max_tokens |
number | 1024 | Max response tokens |
useChat Return
| Field | Type | Description |
|---|---|---|
messages |
Message[] |
Full conversation history |
isLoading |
boolean |
True while request in flight |
error |
AINativeError | null |
Last error, if any |
sendMessage |
(msgs: Message[]) => Promise\x3C...> |
Send next message |
useCredits Hook
import { useCredits } from '@ainative/react-sdk';
function CreditsBar() {
const { balance, isLoading, error, refetch } = useCredits();
if (isLoading) return \x3Cdiv>Loading credits...\x3C/div>;
if (error) return \x3Cdiv>Error: {error.message}\x3C/div>;
return (
\x3Cdiv>
\x3Cspan>{balance?.remaining_credits} credits remaining\x3C/span>
\x3Cspan> | Plan: {balance?.plan}\x3C/span>
\x3Cbutton onClick={refetch}>Refresh\x3C/button>
\x3C/div>
);
}
useCredits Return
| Field | Type | Description |
|---|---|---|
balance |
CreditBalance | null |
Balance data |
isLoading |
boolean |
Fetching state |
error |
AINativeError | null |
Error state |
refetch |
() => void |
Manually refresh |
CreditBalance shape: { remaining_credits: number, plan: string, ... }
Exports
import {
AINativeProvider,
useChat,
useCredits,
useAINativeContext, // access raw config/baseUrl
type Message,
type ChatCompletionResponse,
type CreditBalance,
type AINativeError,
type UseChatOptions,
} from '@ainative/react-sdk';
Environment Variable (CRA / Vite)
REACT_APP_AINATIVE_API_KEY=ak_your_key # CRA
VITE_AINATIVE_API_KEY=ak_your_key # Vite
\x3CAINativeProvider config={{ apiKey: process.env.REACT_APP_AINATIVE_API_KEY! }}>
References
packages/sdks/react/src/hooks/useChat.ts— Hook implementationpackages/sdks/react/src/hooks/useCredits.ts— Credits hookpackages/sdks/react/src/AINativeProvider.tsx— Provider contextpackages/sdks/react/src/index.ts— Package exports
安全使用建议
This instruction-only skill appears to be what it claims (a React SDK for chat and credits), but do a quick provenance check before using it in production: 1) Verify the package on the npm registry (owner, package page, readme, and published version) and confirm the maintainer/trustworthiness since source/homepage are missing. 2) Confirm the correct published version (SKILL.md says 1.0.1 vs metadata 1.0.0). 3) Treat the API key (REACT_APP_AINATIVE_API_KEY / VITE_AINATIVE_API_KEY or provider apiKey) as sensitive: store it in secure env/config and avoid embedding it in client bundles. 4) Inspect the installed package contents (node_modules/@ainative/react-sdk) and its network calls to ensure it only talks to expected endpoints. If you cannot validate the package origin, avoid providing secrets to it.
功能分析
Type: OpenClaw Skill
Name: ainative-react-sdk
Version: 1.0.0
The skill bundle contains standard documentation and usage examples for a React SDK (@ainative/react-sdk). The SKILL.md file provides clear instructions for an AI agent to assist with installing the package, setting up a provider, and using hooks for chat and credit tracking. No malicious code, data exfiltration patterns, or prompt injection attempts were identified.
能力评估
Purpose & Capability
SKILL.md shows a React provider, useChat and useCredits hooks and usage examples that match the skill name/description. Minor inconsistencies: SKILL.md header says published npm v1.0.1 while registry metadata lists version 1.0.0; source and homepage are missing which makes provenance unclear but not contradictory to the documented functionality.
Instruction Scope
Instructions are focused on installing and using the @ainative/react-sdk in a React app (provider config, hooks, env var examples). The runtime instructions do not ask the agent to read unrelated system files or exfiltrate data.
Install Mechanism
This is an instruction-only skill that tells the user to run 'npm install @ainative/react-sdk'. There is no install spec that would download arbitrary archives or write code to disk beyond normal package installation.
Credentials
SKILL.md demonstrates the SDK expects an API key (REACT_APP_AINATIVE_API_KEY / VITE_AINATIVE_API_KEY and a provider config apiKey). However, the skill's metadata lists no required env vars or primary credential. The SDK legitimately needs an API key for operation, so the metadata omission is a provenance/documentation gap rather than a functional impossibility.
Persistence & Privilege
Skill is not flagged always:true and does not request persistent or elevated privileges. It's user-invocable and model invocation is enabled (normal for skills).
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install ainative-react-sdk - 安装完成后,直接呼叫该 Skill 的名称或使用
/ainative-react-sdk触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial public release of ainative-react-sdk.
- Provides React hooks for AI chat (useChat), credit tracking (useCredits), and managed sessions via AINativeProvider.
- Includes TypeScript types and context access (useAINativeContext).
- Documentation covers installation, hook usage, provider setup, handling loading/error states, and environment variable configuration.
- Published as @ainative/react-sdk version 1.0.1 on npm.
元数据
常见问题
Ainative React Sdk 是什么?
Use @ainative/react-sdk to add AI chat and credits to React apps. Use when (1) Installing @ainative/react-sdk, (2) Using the useChat hook for chat completion... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 139 次。
如何安装 Ainative React Sdk?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install ainative-react-sdk」即可一键安装,无需额外配置。
Ainative React Sdk 是免费的吗?
是的,Ainative React Sdk 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Ainative React Sdk 支持哪些平台?
Ainative React Sdk 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Ainative React Sdk?
由 Toby Morning(@urbantech)开发并维护,当前版本 v1.0.0。
推荐 Skills