# Secret vs Public Key

> Understanding the difference between secret and public API keys in Helicone. Learn about access levels, usage examples, and best practices.

import QuestionsSection from "/snippets/questions-section.mdx";

| Key Type   | Access       | Path Auth       | Header Auth | REST API |
| ---------- | ------------ | --------------- | ----------- | -------- |
| **Public** | Write-Only   | Yes             | Yes         | No       |
| **Secret** | Read + Write | Not Recommended | Yes         | Yes      |

### Usage Examples

<CodeGroup>

```javascript Header Auth
import OpenAI from "openai";

// Use secret or public key
const openai = new OpenAI({
  apiKey: request.env.OPENAI_API_KEY,
  baseURL: "https://oai.helicone.ai/v1",
  defaultHeaders: {
    "Helicone-Auth": `Bearer ${HELICONE_SECRET_API_KEY}`,
  },
});
```

```javascript Path Auth
import OpenAI from "openai";

// Use public key
const openai = new OpenAI({
  apiKey: request.env.OPENAI_API_KEY,
  baseURL: `https://oai.helicone.ai/${HELICONE_PUBLIC_API_KEY}/v1`,
});
```

</CodeGroup>

<Note>
  Ensure that secret keys are always kept secure and never exposed in
  client-side code.
</Note>

<QuestionsSection />
