• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
dl4senses

dl4senses

grok_user_search

Public
Like
grok_user_search
Home
Code
13
.claude
1
.vtignore
AGENTS.md
DEPLOYMENT.md
README.md
TROUBLESHOOTING.md
deno.json
grok_client.ts
index.html
H
main.ts
schema.ts
H
test_example.ts
types.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
DEPLOYMENT.md
Code
/
DEPLOYMENT.md
Search
…
DEPLOYMENT.md

Val Town Deployment Guide

This guide provides step-by-step instructions for deploying the Grok X User Search val to Val Town.

Prerequisites

  1. Val Town CLI: Install the Val Town CLI

    npm install -g @val-town/cli
  2. API Key: Get your xAI API key from x.ai

    • Sign up for xAI account
    • Navigate to API section
    • Generate your API key

Deployment Methods

Method 1: Create New Val (Recommended)

Step 1: Navigate to Project Directory

cd /home/didierlacroix1/containers/val-town/individual_vals/grok_user_search

Step 2: Create New Val

vt create grokUserSearch

Note: This will prompt asking if you want to use existing files. Type y to continue.

Step 3: Push Code to Val Town

vt push

Step 4: Set Environment Variable

Go to your Val Town dashboard β†’ Settings β†’ Environment Variables and add:

  • Key: XAI_API_KEY
  • Value: Your xAI API key

Method 2: Create from Empty Directory

Step 1: Create Empty Val

cd /home/didierlacroix1/containers/val-town/individual_vals mkdir grok_search_empty cd grok_search_empty vt create grokUserSearch

Step 2: Copy Files

cp ../grok_user_search/* .

Step 3: Push to Val Town

vt push

Method 3: Manual Upload

  1. Create New Val in Val Town web interface
  2. Upload Files manually:
    • main.ts
    • grok_client.ts
    • types.ts
    • deno.json
    • index.html (Web UI)

Post-Deployment Configuration

1. Environment Variables

In Val Town dashboard, set:

XAI_API_KEY=your_xai_api_key_here

2. Test the Val

Web Interface (Recommended): Visit your val's URL in a web browser:

https://your-username-grokUserSearch.web.val.run

API Test:

curl -X POST https://your-username-grokUserSearch.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "find all the latest prompts mentioned", "targetUser": "dl4senses" }'

3. Verify Setup

  • Check val runs without errors
  • Test with different queries
  • Verify API responses include citations

Development Workflow

Local Development

cd /home/didierlacroix1/containers/val-town/individual_vals/grok_user_search vt watch

This will automatically sync changes to Val Town.

Making Updates

  1. Edit files locally
  2. vt push to upload changes
  3. Test the updated val

Pulling Changes from Val Town

vt pull

Common Issues & Solutions

Issue: "Directory not empty" Error

Solution: This is expected - type y when prompted to continue with existing files.

Issue: API Key Not Found

Solution: Ensure XAI_API_KEY is set in Val Town dashboard β†’ Settings β†’ Environment Variables.

Issue: Import Errors

Solution: Check that all TypeScript imports are correct and files exist in the val.

Issue: CORS Errors

Solution: The code includes CORS headers, but verify your browser isn't blocking requests.

API Usage Examples

Basic Search

curl -X POST https://your-val-url.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "latest AI developments", "maxResults": 10 }'

Target User Search

curl -X POST https://your-val-url.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "find all the latest prompts mentioned by @dl4senses", "targetUser": "dl4senses", "includeMedia": true }'

Date Range Search

curl -X POST https://your-val-url.web.val.run \ -H "Content-Type: application/json" \ -d '{ "query": "AI breakthroughs", "dateRange": { "from": "2025-01-01", "to": "2025-01-15" } }'

Monitoring & Logs

View Val Logs

In Val Town dashboard:

  1. Go to your val
  2. Click "Logs" tab
  3. View request logs and error messages

Monitor API Usage

Check xAI dashboard for:

  • API request counts
  • Token usage
  • Rate limiting

Security Considerations

  1. API Key Security: Never commit API keys to code
  2. Input Validation: Code includes input sanitization
  3. Rate Limiting: Monitor and respect xAI rate limits
  4. Error Handling: Errors don't expose sensitive information

Scaling & Performance

  • The val runs serverless on Val Town
  • xAI handles the heavy processing
  • Consider response times for complex queries
  • Monitor token usage for cost management

Support

For issues:

  • Val Town Issues: Check Val Town documentation
  • xAI API Issues: Check x.ai documentation
  • Code Issues: Review implementation and test locally

Next Steps

After successful deployment:

  1. Test with various queries
  2. Monitor API usage and costs
  3. Consider adding caching for repeated queries
  4. Implement rate limiting if needed
  5. Add analytics for query patterns
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.