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

peterqliu

PineconeIndex

Vector db's on Pinecone, with OpenAI embeddings
Public
Like
PineconeIndex
Home
Code
3
PineconeIndex
README.md
H
sample_server
Branches
1
Pull requests
Remixes
History
Environment variables
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
/
/
x
/
peterqliu
/
PineconeIndex
/
branch
/
main
/
version
/
88
/
code
/
README.md
/
README.md
Code
/
/
x
/
peterqliu
/
PineconeIndex
/
branch
/
main
/
version
/
88
/
code
/
README.md
/
README.md
Search
…
Viewing readonly version of main branch: v88
View latest version
README.md

PineconeIndex HTTP Server

This project provides an HTTP interface for the PineconeIndex class, allowing you to interact with your Pinecone vector database through REST API endpoints.

Setup

  1. Set your environment variables:

    • PINECONE_KEY: Your Pinecone API key
    • OPENAI_KEY: Your OpenAI API key
  2. The HTTP server is available at /pinecone_http_server

API Endpoints

Health Check

GET /health/

Returns the server status and configuration check.

Query Index

POST /query/
Content-Type: application/json

{
  "query": "your search text here"
}

Or simply send a string directly:

POST /query/
Content-Type: application/json

"your search text here"

Add Documents

POST /upsert/
Content-Type: application/json

{
  "texts": ["document 1", "document 2", "document 3"]
}

Clear Index

POST /empty/

Clears all vectors from the index/namespace.

Usage Examples

JavaScript/TypeScript

// Query the index const response = await fetch('https://your-val-url.web.val.run/query/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: 'machine learning' }) }); const results = await response.json(); // Add documents await fetch('https://your-val-url.web.val.run/upsert/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ texts: ['AI is transforming industries', 'Machine learning enables automation'] }) });

cURL

# Health check curl https://your-val-url.web.val.run/health/ # Query curl -X POST https://your-val-url.web.val.run/query/ \ -H "Content-Type: application/json" \ -d '{"query": "artificial intelligence"}' # Add documents curl -X POST https://your-val-url.web.val.run/upsert/ \ -H "Content-Type: application/json" \ -d '{"texts": ["Document 1 content", "Document 2 content"]}'

Features

  • Automatic routing: The handleRequest method in PineconeIndex automatically routes requests based on URL path
  • Error handling: Comprehensive error handling with helpful messages
  • Flexible input: Query endpoint accepts both string and object formats
  • Environment validation: Clear feedback when API keys are missing
  • Health monitoring: Built-in health check endpoint

Class Methods

The enhanced PineconeIndex class now includes:

  • handleRequest(req: Request): Main HTTP router
  • _handleQuery(req: Request): Process query requests
  • _handleUpsert(req: Request): Process document uploads
  • _handleEmpty(req: Request): Process index clearing requests

All existing methods (query, upsertRecords, empty, etc.) remain unchanged and work as before.

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.