Overview
This tutorial demonstrates how to use Nuwa LLM Gateway combined with OpenAI’s File Search functionality to build a paid professional knowledge retrieval service. We’ll use Nuwa Improvement Proposals (NIPs) as our knowledge base, showing how to transform specialized technical documentation into a profitable AI service.Live Example
You can see a working example of this approach in action: Nuwa Protocol Helper - a Cap that provides expert assistance with Nuwa protocol questions using the same techniques described in this tutorial.Why Choose Specialized Documentation?
Through experimentation, we’ve found that for publicly available and well-known documents, using Vector Store with File Search often doesn’t provide significant advantages over standard LLM APIs with web search enabled. This is because popular, public documentation is already well-covered in LLM training data and easily accessible through web search. However, Vector Store with File Search provides significant value improvement in two specific scenarios:- Private Documentation - Internal documents that AI cannot access through public channels
- New Documentation - Latest documents not yet included or insufficiently covered in AI training data
Expected Effect Comparison
With Vector Store Enhancement:- Provides specific configuration file examples and parameter explanations
- References accurate environment variable names and values
- Offers detailed troubleshooting steps and solutions
- Includes actual deployment commands and verification methods
- Only provides general conceptual explanations
- Cannot give Nuwa-specific configuration parameters
- Lacks targeted deployment and troubleshooting guidance
- Missing specific code examples and commands
Prerequisites
Before starting this tutorial, ensure you have:- API Keys: Service Key and OpenAI API Key
- Cloud Platform Access: Railway account (or other cloud platform) for deploying your LLM Gateway
- Basic Knowledge: Familiarity with Nuwa ecosystem and Cap Studio
1. Obtain Required API Keys
1
Get Service Key
Follow the Service Key guide to create your service DID and obtain a Service Key:
2
Get OpenAI API Key
- Visit OpenAI Platform
- Create an API Key
- Ensure your account has sufficient balance for File Search functionality
2. Prepare Documentation Files
We’ll use Nuwa Improvement Proposals (NIPs) as our knowledge base. NIPs are technical specifications that define core Nuwa protocols, containing detailed technical specifications, implementation requirements, and protocol definitions that are not well-covered in general AI training data. The NIP documents are located in thenips/nips/ directory of the Nuwa repository and include:
- NIP-0 - NIP Purpose and Guidelines
- NIP-1 - Agent Single DID Multi-Key Model
- NIP-2 - DIDAuth v1 Authentication Protocol
- NIP-3 - Custodian-Assisted DID Onboarding Protocol (CADOP)
- NIP-4 - Unidirectional Payment Channel Core
- And other protocol specifications…
Step 1: Create OpenAI Vector Store
1
Login to OpenAI Platform
Visit OpenAI Platform and log into your account.
2
Create Vector Store
- Find the “Storage” section in the left navigation bar
- Click “Vector stores”
- Click “Create vector store”
- Name your vector store, for example: “Nuwa Docs”
- Click “Create”
3
Upload Documentation Files
Upload NIP documentation to Vector Store:Since OpenAI Vector Store doesn’t directly support Upload Process:
.md files, you need to convert them to a supported format:Method A: Convert to TXT files (Recommended)- Navigate to the
nips/nips/directory in your Nuwa repository - For each NIP file (nip-0.md, nip-1.md, nip-2.md, etc.):
- Copy the content of the
.mdfile - Create a new
.txtfile with the same name (e.g.,nip-1.txt) - Paste the content (Markdown syntax will be preserved as plain text)
- Copy the content of the
- Upload all
.txtfiles to Vector Store
- In the created vector store page, click “Add files”
- Select all converted
.txtfiles - Upload them to the Vector Store
- Wait for file processing to complete

4
Record Vector Store ID
After upload completion, record your Vector Store ID (format like
vs_xxx), which will be used in subsequent configuration.Step 2: Deploy LLM Gateway to Production
1
Deploy to Railway
Before creating the Cap, we need a production LLM Gateway. Follow the LLM Gateway Railway deployment guide to:
- Create a Railway service
- Deploy using Docker image:
ghcr.io/nuwa-protocol/llm-gateway:latest - Configure environment variables:
SERVICE_KEY: Your Nuwa service keyOPENAI_API_KEY: Your OpenAI API keyROOCH_NETWORK: Set totestnetormainnet
- Generate a public domain (e.g.,
https://your-gateway.up.railway.app)
Step 3: Create Knowledge Retrieval Cap in Cap Studio
1
Access Cap Studio
- Open Nuwa Client Beta
- Login with device passkey and create DID
- Go to Settings → System → Enable Developer Mode
- Find and click “Cap Studio” in the sidebar
2
Create New Cap
- Click “New Cap” in Cap Studio
- Choose to use the online editor (recommended)
3
Configure Basic Information
Fill in the Cap’s basic information:
- Cap Name:
nuwa_protocol_helper - Display Name:
Nuwa Protocol Helper - Description:
Technical helper for Nuwa protocol specifications and NIPs - Tags:
Tools
4
Configure Prompt
Set the system prompt:Prompt Suggestions:
How does the DID work in Nuwa protocol?What are the verification relationships in Nuwa DID?How does the payment channels work in Nuwa protocol?
5
Configure Model
Select model configuration:
- Provider:
openai_responses - Model:
gpt-4o - Custom Gateway URL:
https://your-gateway.up.railway.app(use your actual Railway domain) - Supported Inputs:
text - Context Length:
128000
openai_responses instead of openai_chat_completion because we need to use OpenAI’s Responses API to support File Search functionality.6
Configure File Search Tool
In the Model configuration Parameters section, add the File Search tool:
Replace
vs_your_vector_store_id with your actual Vector Store ID from Step 1 (format: vs_xxx).7
Step 4: Test and Verify Effects
1
Save and Test Cap
- Click “Save” in Cap Studio to save the configuration
- Click “Test” to enter test mode
-
Start testing various NIP-related questions, such as:
- “How does DIDAuth v1 authentication work in Nuwa?”
- “What are the key components of Nuwa’s payment channel protocol?”

2
Effect Comparison Verification
To verify the value of Vector Store, you can:
- First disable File Search: Temporarily remove tools configuration and test the same questions
- Record generic responses: Observe the generic responses given by AI
- Re-enable File Search: Restore tools configuration
- Compare professional responses: Observe specific responses based on documentation
- Responses are more specific and accurate after enabling File Search
- Include actual configuration parameters and command examples
- Provide targeted troubleshooting steps
- Reference specific documentation content and best practices
Step 5: Publish Cap and Start Monetizing
1
Improve Cap Information
Before publishing, enhance your Cap:
- Add thumbnail: Upload a representative image
- Improve introduction: Detailed description of Cap functionality and use cases
- Set tags: Add relevant tags for easier discovery
- Configure pricing: Set reasonable prices through LLM Gateway pricing configuration
2
Submit to Cap Store
- Click “Submit to Store” in Cap Studio
- Review and confirm all information
- The Cap will be published immediately after confirmation (no approval process needed)
- Your Cap will be visible in the Cap Store right away
3
Promote Your Cap
- Share with target users: Promote to Nuwa developers and blockchain community
- Collect user feedback: Optimize response quality based on usage
- Continuously update documentation: Keep Vector Store documents up to date
Revenue Management
1
Monitor Usage
Monitor your Cap usage through the following methods:
- LLM Gateway logs: View request logs and usage statistics
- OpenAI usage statistics: Check File Search usage in OpenAI Platform
- Nuwa revenue panel: View revenue statistics in Agent DID page
2
View and Withdraw Revenue
Manage your revenue according to the Revenue guide:
3
Optimize Pricing Strategy
Adjust pricing based on usage:
- Analyze user behavior: Which questions are most frequently asked
- Evaluate response quality: Complex questions can be priced higher
- Adjust Gateway configuration: Use
PRICING_MULTIPLIERto adjust overall pricing - A/B testing: Try different price points to find optimal balance
Extension and Optimization
Add More Documentation
You can continue expanding your Vector Store with additional Nuwa documentation:- SDK Documentation - Add Nuwa Kit documentation (Identity Kit, Payment Kit, Cap Kit, UI Kit)
- Implementation examples - Include code examples and reference implementations from the repository
- Protocol updates - Keep NIPs updated with latest revisions as they evolve
- Build guides - Add protocol specifications, LLM Gateway, and other service documentation
Optimize Retrieval Effectiveness
- Document structuring: Ensure documents have clear titles and sections
- Add metadata: Add tags and classification information to documents
- Regular updates: Keep documents in Vector Store up to date
- User feedback: Optimize document content based on user questions
Troubleshooting
Common Issues
File Search not working- Check if Vector Store ID is correct
- Confirm documents have been successfully uploaded and processed
- Verify OpenAI API Key has sufficient permissions and balance
- Ensure files are in supported format (TXT, PDF, DOC, etc.) - MD files need conversion
- Check if SERVICE_KEY is correctly set
- Confirm network configuration and ports have no conflicts
- Review Gateway logs to troubleshoot specific errors
- Verify Custom Gateway URL configuration is correct
- Check if Model Provider selected
openai_responses - Confirm tools configuration format is correct
- Confirm users actually used your Cap
- Check if payment channels are correctly configured
- Revenue panel updates may have delays
Summary
Through this tutorial, you have learned:- Identify high-value documents: Choose private or new documents as Vector Store content
- Build knowledge services: Use LLM Gateway + OpenAI File Search to create professional Q&A services
- Achieve business closure: Complete process from technical implementation to revenue management
- Optimize user experience: Provide more accurate answers than generic AI through professional documentation
- Enterprise internal documentation: Provide internal knowledge retrieval for company employees
- Technical documentation services: Provide professional Q&A for specific technology stacks for developers
- Regulatory compliance assistant: Provide compliance guidance based on latest regulatory documents
- Medical knowledge base: Provide clinical guideline retrieval for medical professionals

