본문으로 건너뛰기
cccskills
무료GitHub에 공개

x-request

Focus on explaining the practical configuration and usage of XRequest, providing accurate configuration instructions based on official documentation

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(4)

  • SKILL.md10.9 KB
  • reference/API.md5.5 KB
  • reference/CORE.md5.9 KB
  • reference/EXAMPLES_SERVICE_PROVIDER.md2.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

🎯 Skill Positioning

This skill focuses on solving: How to correctly configure XRequest to adapt to various streaming interface requirements.

Table of Contents

🚀 Quick Start

Dependency Management

📋 System Requirements

PackageVersion RequirementAuto InstallPurpose
@ant-design/x-sdk≥2.2.2✅Core SDK, includes XRequest tool

🛠️ One-click Installation

# Recommended to use tnpm
tnpm install @ant-design/x-sdk

# Or use npm
npm add @ant-design/x-sdk

# Check version
npm ls @ant-design/x-sdk

Basic Configuration

Simplest Usage

import { XRequest } from '@ant-design/x-sdk';

// Minimal configuration: only need to provide API URL
const request = XRequest('https://api.example.com/chat');

// For manual control (used in Provider scenarios)
const providerRequest = XRequest('https://api.example.com/chat', {
  manual: true, // Usually only this needs explicit configuration
});

💡 Tip: XRequest has built-in reasonable default configurations. In most cases, you only need to provide the API URL to use it.

📦 Technology Stack Overview

🏗️ Technology Stack Architecture

graph TD
    A[XRequest] --> B[Network Requests]
    A --> C[Authentication Management]
    A --> D[Error Handling]
    A --> E[Streaming Processing]
    B --> F[fetch Wrapper]
    C --> G[Token Management]
    D --> H[Retry Mechanism]
    E --> I[Server-Sent Events]

🔑 Core Concepts

ConceptRole PositioningCore ResponsibilitiesUsage Scenarios
XRequest🌐 Request ToolHandle all network communication, authentication, error handlingUnified request management
Global Config⚙️ Config CenterConfigure once, use everywhereReduce duplicate code
Streaming Config🔄 Streaming ProcessingSupport SSE and JSON response formatsAI conversation scenarios

🔧 Core Configuration Details

Core functionality reference content CORE.md

🛡️ Security Guide

Environment Security Configuration

🌍 Security Strategies for Different Environments

Runtime EnvironmentSecurity LevelConfiguration MethodRisk Description
Browser Frontend🔴 High Risk❌ Prohibit key configurationKeys will be directly exposed to users
Node.js Backend🟢 Safe✅ Environment variable configurationKeys stored on server side
Proxy Service🟢 Safe✅ Same-origin proxy forwardingKeys managed by proxy service

🔐 Authentication Methods Comparison

Authentication MethodApplicable EnvironmentConfiguration ExampleSecurity
Bearer TokenNode.jsBearer ${process.env.API_KEY}✅ Safe
API Key HeaderNode.jsX-API-Key: ${process.env.KEY}✅ Safe
Proxy ForwardingBrowser/api/proxy/service✅ Safe
Direct ConfigurationBrowserBearer sk-xxx❌ Dangerous

🔍 Debugging and Testing

Debug Configuration

🛠️ Debug Templates

Node.js Debug Configuration:

// Safe debug configuration (Node.js environment)
const debugRequest = XRequest('https://your-api.com/chat', {
  headers: {
    Authorization: `Bearer ${process.env.DEBUG_API_KEY}`,
  },
  params: { query: 'test message' },
});

Frontend Debug Configuration:

// Safe debug configuration (frontend environment)
const debugRequest = XRequest('/api/debug/chat', {
  params: { query: 'test message' },
});

Configuration Validation

✅ Security Check Tools

// Security configuration validation function
const validateSecurity = (config: any) => {
  const isBrowser = typeof window !== 'undefined';
  const hasAuth = config.headers?.Authorization || config.headers?.authorization;

  if (isBrowser && hasAuth) {
    throw new Error(
      '❌ Frontend environment prohibits Authorization configuration, risk of key leakage!',
    );
  }

  console.log('✅ Security configuration check passed');
  return true;
};

// Usage example
validateSecurity({
  headers: {
    // Do not include Authorization
  },
});

📋 Usage Scenarios

Standalone Usage

🎯 Direct Request Initiation

import { XRequest } from '@ant-design/x-sdk';

// Test interface availability
const testRequest = XRequest('https://httpbin.org/post', {
  params: { test: 'data' },
});

// Send request immediately
const response = await testRequest();
console.log(response);

Integration with Other Skills

🔄 Skill Collaboration Workflow

graph TD
    A[x-request] -->|Configure Request| B[x-chat-provider]
    A -->|Configure Request| C[use-x-chat]
    B -->|Provide Provider| C
    A --> D[Direct Request]
Usage MethodCooperating SkillPurposeExample
StandaloneNoneDirect network request initiationTest interface availability
With x-chat-providerx-chat-providerConfigure requests for custom ProviderConfigure private API
With use-x-chatuse-x-chatConfigure requests for built-in ProviderConfigure OpenAI API
Complete AI Applicationx-request → x-chat-provider → use-x-chatConfigure requests for entire systemComplete AI conversation application

⚠️ useXChat Integration Security Warning

Important Warning: useXChat is only for frontend environments, XRequest configuration must not contain Authorization!

❌ Incorrect Configuration (Dangerous):

// Extremely dangerous: keys will be directly exposed to browser
const unsafeRequest = XRequest('https://api.openai.com/v1/chat/completions', {
  headers: {
    Authorization: 'Bearer sk-xxxxxxxxxxxxxx', // ❌ Dangerous!
  },
  manual: true,
});

✅ Correct Configuration (Safe):

// Frontend security configuration: use proxy service
const safeRequest = XRequest('/api/proxy/openai', {
  params: {
    model: 'gpt-3.5-turbo',
    stream: true,
  },
  manual: true,
});

🚨 Development Rules

Test Case Rules

  • If the user does not explicitly need test cases, do not add test files
  • Only create test cases when the user explicitly requests them

Code Quality Rules

  • After completion, must check types: Run tsc --noEmit to ensure no type errors
  • Keep code clean: Remove all unused variables and imports

✅ Configuration Checklist

Before using XRequest, please confirm the following configurations are correctly set:

🔍 Configuration Checklist

Check ItemStatusDescription
API URL✅ Must ConfigureXRequest('https://api.xxx.com')
Auth Info⚠️ Environment RelatedFrontend❌Prohibited, Node.js✅Available
manual Config✅ Provider ScenarioIn Provider needs to be set to true, other scenarios need to be set according to actual situation
Other Config❌ No Need to ConfigureBuilt-in reasonable default values
Interface Availability✅ Recommended TestVerify with debug configuration

🛠️ Quick Verification Script

// Check configuration before running
const checkConfig = () => {
  const checks = [
    {
      name: 'Global Configuration',
      test: () => {
        // Check if global configuration has been set
        return true; // Check according to actual situation
      },
    },
    {
      name: 'Security Configuration',
      test: () => validateSecurity(globalConfig),
    },
    {
      name: 'Type Check',
      test: () => {
        // Run tsc --noEmit
        return true;
      },
    },
  ];

  checks.forEach((check) => {
    console.log(`${check.name}: ${check.test() ? '✅' : '❌'}`);
  });
};

🎯 Skill Collaboration

graph LR
    A[x-request] -->|Configure Request| B[x-chat-provider]
    A -->|Configure Request| C[use-x-chat]
    B -->|Provide Provider| C

📊 Skill Usage Comparison Table

Usage ScenarioRequired SkillsUsage OrderCompletion Time
Test Interfacex-requestDirect Use2 minutes
Private API Adaptationx-request → x-chat-providerConfigure request first, then create Provider10 minutes
Standard AI Applicationx-request → use-x-chatConfigure request first, then build interface15 minutes
Complete Customizationx-request → x-chat-provider → use-x-chatComplete workflow30 minutes

🔗 Reference Resources

📚 Core Reference Documentation

🌐 SDK Official Documentation

💻 Example Code

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

专注讲解如何使用 useXChat Hook,包括自定义 Provider 的集成、消息管理、错误处理、多会话管理等

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ant-design/x4.8천2026년 10월 12일 업데이트

Focus on explaining how to use the useXChat Hook, including custom Provider integration, message management, error handling, multi-conversation management, and more

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ant-design/x4.8천2026년 10월 12일 업데이트

x-card

무료

当需要用 @ant-design/x-card 让 AI Agent 动态渲染富交互 UI 时使用——涵盖 XCard.Box、XCard.Card、A2UI v0.9 命令、数据绑定、Catalog、Actions 和流式渲染模式。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ant-design/x4.8천2026년 10월 12일 업데이트

x-card

무료

Use when building AI-driven UIs with @ant-design/x-card — covers XCard.Box, XCard.Card, A2UI v0.9 commands, data binding, catalogs, actions, and streaming patterns.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ant-design/x4.8천2026년 10월 12일 업데이트

专注于自定义 Chat Provider 的实现,帮助将任意流式接口适配为 Ant Design X 标准格式

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ant-design/x4.8천2026년 10월 12일 업데이트

Focus on implementing custom Chat Provider, helping to adapt any streaming interface to Ant Design X standard format

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ant-design/x4.8천2026년 10월 12일 업데이트

ant-design의 스킬 모두 보기

이 스킬의 문제 신고