Where should an application keep the API key it uses to call a hosted model?
- Exam domain
- Developing and deploying generative AI solutions
- Difficulty
- Medium
- In this mock
- 5 questions on this domainPractise this domain
Why B is the answer
In a secrets manager or environment variable, never in source code
Keys belong in a secrets store or server-side environment. Anything in code, prompts or the browser can leak.
Remember: Keys stay server-side.
In detail
- Server-side secrets.
- Rotate keys.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. In the README for the team to findWrong
A README is public to anyone with the repo.
B. In a secrets manager or environment variable, never in source codeRight
Keys stay server-side.
C. In the prompt, so the model can authenticate itselfWrong
A prompt is not a place for credentials.
D. In the front-end JavaScript, so the browser can call the model without a backendWrong
Browser code exposes the key to every user.
Use case
An illustrative scenario, not a real incident.
Illustrative: a team moves its key from a front-end bundle into a backend secret after a leak scan.
See it in different ways
mindmap
root(("API key"))
n1["Yes"]
n2["Secrets manager"]
n3["Server env variable"]
n4["No"]
n5["Code"]
n6["Prompt"]
n7["Browser"]How to read this chart
- The centre is "API key".
- "Yes" covers "Secrets manager", "Server env variable".
- "No" covers "Code", "Prompt", "Browser".
sequenceDiagram participant P0 as Browser participant P1 as Backend participant P2 as Model API P0->>P1: request P1->>P2: call with secret key P2-->>P1: response P1-->>P0: answer
How to read this chart
- 1. Browser sends "request" to Backend.
- 2. Backend sends "call with secret key" to Model API.
- 3. Backend gets a reply from Model API: "response".
- 4. Browser gets a reply from Backend: "answer".