• 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
/
89
/
code
/
README.md
/
README.md
Code
/
/
x
/
peterqliu
/
PineconeIndex
/
branch
/
main
/
version
/
89
/
code
/
README.md
/
README.md
Search
…
Viewing readonly version of main branch: v89
View latest version
README.md

PineconeIndex HTTP API

A simple HTTP interface for querying and managing your Pinecone vector database. Search through your documents using natural language queries via REST API endpoints.

Quick Start

  1. Set Environment Variables

    • PINECONE_KEY: Your Pinecone API key
    • OPENAI_KEY: Your OpenAI API key
  2. Use the API

    # Search your documents curl -X POST https://your-val-url.web.val.run/query/ \ -H "Content-Type: application/json" \ -d '"machine learning applications"'

API Reference

Search Documents

Find the most relevant documents for your query.

POST /query/

Request Body:

"your search query here"

or

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

Response:

{ "matches": [ { "id": "doc-123", "score": 0.95, "metadata": { "text": "Machine learning is transforming..." } } ] }

Add Documents

Upload new documents to your index.

POST /upsert/

Request Body:

{ "texts": [ "First document content", "Second document content" ] }

Response:

{ "success": true, "count": 2 }

Clear Index

Remove all documents from your index.

POST /empty/

Response:

{ "success": true, "message": "Index cleared" }

Health Check

Check if the service is running and configured properly.

GET /health/

Response:

{ "status": "healthy", "timestamp": "2025-12-20T19:21:17.737Z", "config": { "pineconeKey": "✓ Set", "openaiKey": "✓ Set" } }

Usage Examples

JavaScript

const API_URL = 'https://your-val-url.web.val.run'; // Search for documents async function search(query) { const response = await fetch(`${API_URL}/query/`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(query) }); return response.json(); } // Add new documents async function addDocuments(texts) { const response = await fetch(`${API_URL}/upsert/`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ texts }) }); return response.json(); } // Example usage const results = await search('artificial intelligence trends'); await addDocuments(['AI is revolutionizing healthcare', 'Machine learning in finance']);

Python

import requests API_URL = 'https://your-val-url.web.val.run' # Search documents def search(query): response = requests.post(f'{API_URL}/query/', json=query) return response.json() # Add documents def add_documents(texts): response = requests.post(f'{API_URL}/upsert/', json={'texts': texts}) return response.json() # Example usage results = search('climate change solutions') add_documents(['Solar energy is becoming more efficient', 'Wind power costs are decreasing'])

cURL

# Search curl -X POST https://your-val-url.web.val.run/query/ \ -H "Content-Type: application/json" \ -d '"renewable energy technologies"' # Add documents curl -X POST https://your-val-url.web.val.run/upsert/ \ -H "Content-Type: application/json" \ -d '{"texts": ["Document 1", "Document 2"]}' # Clear index curl -X POST https://your-val-url.web.val.run/empty/ # Health check curl https://your-val-url.web.val.run/health/

Error Handling

The API returns standard HTTP status codes:

  • 200 - Success
  • 400 - Bad Request (missing required fields)
  • 405 - Method Not Allowed (wrong HTTP method)
  • 500 - Server Error (API key issues, service problems)

Error responses include helpful messages:

{ "error": "Query text is required", "hint": "Make sure PINECONE_KEY and OPENAI_KEY environment variables are set" }

Configuration

The service uses these default settings:

  • Index: wikipedia-simple-text-embedding-ada-002-250k
  • Model: text-embedding-ada-002
  • Dimensions: 1536
  • Results: Top 10 matches per query

To customize these settings, modify the PineconeIndex configuration in the code.

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.