pinecone-ts-client icon indicating copy to clipboard operation
pinecone-ts-client copied to clipboard

No HTTP proxy support

Open Nevon opened this issue 2 years ago • 1 comments

The PineconeClient doesn't expose any of the options by the underlying API client, which means there's no way to configure it to use an HTTP proxy, or more generally control the behavior of the HTTP client, such as keep-alive. This makes it difficult to use in controlled environments.

The generated api client exposes a fetchApi option where you can supply a fetch-compatible implementation, where you could inject such functionality. Unfortunately the native fetch API doesn't support node's Agent interface, so you'd have to swap it out and do some mapping, but at least it's possible. Something like:

import undici, { RequestInit, ProxyAgent } from 'undici'

const dispatcher = new ProxyAgent(process.env.HTTPS_PROXY!)
const configuration = {
  environment,
  apiKey,
  fetch: async (input: string | URL, init?: RequestInit) => {
    return undici.fetch(input, { ...init, dispatcher })
  }
}
await client.init(configuration)

An example of another API client that I think is generated using the same tooling that you are using, which does support this, is the Adobe Target SDK

Nevon avatar Mar 29 '23 11:03 Nevon

@Nevon thanks for the feedback! We'll definitely looking into and look into how we can support use cases like yours.

gdj0nes avatar Mar 30 '23 17:03 gdj0nes

Hey @Nevon just wanted to chime in and say that this is on my to-do list for the upcoming quarter or two! We haven't forgotten about you :)

aulorbe avatar Aug 27 '24 00:08 aulorbe

Hey all, proxy support is enabled in the client. Now, see the README for instructions.

aulorbe avatar Sep 25 '24 20:09 aulorbe