# Authentication issues -- OpenAI Python Quick Start Guide

**URL:** <https://community.sambanova.ai/t/authentication-issues-openai-python-quick-start-guide/226>\
**Category:** Discussion\
**Tags:** dev\
**Created:** [September 6, 2024, 8:51am UTC](https://community.sambanova.ai/t/authentication-issues-openai-python-quick-start-guide/226 "2024-09-06T08:51:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alnreddy](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/alnreddy/32/247_2.png) [@alnreddy](https://community.sambanova.ai/u/alnreddy)\
**Post date:** [September 6, 2024, 8:51am UTC](https://community.sambanova.ai/t/authentication-issues-openai-python-quick-start-guide/226/1 "2024-09-06T08:51:10Z")

</div>

Hi  
I signed up for Fast API and received “Personal API Key” and " API Endpoint". I plugged those two into OpenAI Python Quick Start Guide ([https://community.sambanova.ai/t/openai-python-quick-start-guide/182](https://community.sambanova.ai/t/openai-python-quick-start-guide/182)). However, when I run the program (in CoLabs for context), I get the following error:  
AuthenticationError:

401 Authorization Required
# 401 Authorization Required

* * *
nginx
## And, here is the error exception stack:

AuthenticationError Traceback (most recent call last)  
 in \<cell line: 24\>()  
22 sys\_prompt = “Answer the question in a couple sentences.”  
23 prompt = “Share a happy story with me”  
—\> 24 out = call\_llama(sys\_prompt, prompt)  
25 print(out)

5 frames  
/usr/local/lib/python3.10/dist-packages/openai/\_base\_client.py in \_request(self, cast\_to, options, remaining\_retries, stream, stream\_cls)  
1039  
1040 log.debug(“Re-raising status error”)  
 → 1041 raise self.\_make\_status\_error\_from\_response(err.response) from None  
1042  
1043 return self.\_process\_response(

## For Reference, here is the code – Note: no changes other than updating API key and URL. I intentionally corrupted the API key for this post

import openai  
from openai import OpenAI  
SAMBANOVA\_API\_URL = “[https://fast-api.snova.ai/v1/chat/completions](https://fast-api.snova.ai/v1/chat/completions)”  
SAMBANOVA\_API\_KEY = “skhsakhfkYaldQyajaWwuY29tAKHKasssZ1B2dlI=” # corrupted key  
client = OpenAI(  
base\_url=SAMBANOVA\_API\_URL, # the endpoint IP running on vLLM  
api\_key=SAMBANOVA\_API\_KEY,  
)  
def call\_llama(sys\_prompt, prompt, \*\*kwargs):  
completion = client.chat.completions.create(  
model=“Meta-Llama-3.1-8B-Instruct”,  
messages=[  
{“role”: “user”, “content”: prompt}  
],  
stream=True,  
\*\*kwargs,  
)  
response = “”  
for chunk in completion:  
response += chunk.choices[0].delta.content or “”  
return response  
sys\_prompt = “Answer the question in a couple sentences.”  
prompt = “Share a happy story with me”  
out = call\_llama(sys\_prompt, prompt)  
print(out)

---

<div class="post-metadata">

**Author:** ![alex.penketh](https://sea1.discourse-cdn.com/sambanova/user_avatar/community.sambanova.ai/alex.penketh/32/348_2.png) [@alex.penketh](https://community.sambanova.ai/u/alex.penketh)\
**Post date:** [September 6, 2024, 1:52pm UTC](https://community.sambanova.ai/t/authentication-issues-openai-python-quick-start-guide/226/2 "2024-09-06T13:52:42Z")

</div>

Hi!

Welcome to the SambaNova community and thanks for registering for the Fast API Program. I will investigate this for you and as this is an access issue provide you an update privately as soon as we are able.

Kind Regards  
Alex Penketh
