# Java SDK setup

## Pattern

Build the client once at startup with the API key sourced from environment or secret config, then derive index handles per index name. Reuse the client across requests; it holds the connection pool.

## Rules for agents

1. One client per process, shared. Constructing a client per request leaks connections and slows everything.
2. API key from environment or your secret manager, never a string literal, never a properties file committed to git.
3. Same index lifecycle: create is async, poll describe until ready before writing.
4. Wrap data-plane calls with your own retry for 429/5xx with backoff and jitter; do not retry other 4xx.

## Trap

Java examples floating around use very old client versions with different package names. Check the artifact coordinates against the current pinecone-io GitHub org before copying dependency snippets.