-
Notifications
You must be signed in to change notification settings - Fork 474
Closed
Labels
component:python sdkIssue/PR related to Python SDKIssue/PR related to Python SDKstatus:awaiting user responseAwaiting a response from the authorAwaiting a response from the authorstatus:staleIssue/PR will be closed automatically if there's no further activityIssue/PR will be closed automatically if there's no further activitytype:questionSupport-related issuesSupport-related issues
Description
Using curl in the terminal works just fine.
curl \
-H 'Content-Type: application/json' \
-d '{ "prompt": { "text": "Write a story about a magic backpack"} }' \
"https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText?key=<my_api_key>"
The above works just fine, however, when I try:
import google.generativeai as palm
palm.configure(api_key=<my_api_key>)
result = palm.generate_text(prompt="The opposite of hot is")
print(result)
Results in the following error:
Traceback (most recent call last):
File "/home/gene/webhook/venv/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 72, in error_remapped_callable
return callable_(*args, **kwargs)
File "/home/gene/webhook/venv/lib/python3.10/site-packages/grpc/_channel.py", line 1030, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/gene/webhook/venv/lib/python3.10/site-packages/grpc/_channel.py", line 910, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "403:Forbidden"
debug_error_string = "UNKNOWN:Error received from peer {grpc_message:"403:Forbidden", grpc_status:14, created_time:"2023-05-25T16:47:54.953534672+00:00"}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/gene/webhook/create_youtubedb.py", line 329, in <module>
test2()
File "/home/gene/webhook/create_youtubedb.py", line 326, in test2
return palm.generate_text(prompt="The opposite of hot is")
File "/home/gene/webhook/venv/lib/python3.10/site-packages/google/generativeai/text.py", line 139, in generate_text
return _generate_response(client=client, request=request)
File "/home/gene/webhook/venv/lib/python3.10/site-packages/google/generativeai/text.py", line 159, in _generate_response
response = client.generate_text(request)
File "/home/gene/webhook/venv/lib/python3.10/site-packages/google/ai/generativelanguage_v1beta2/services/text_service/client.py", line 641, in generate_text
response = rpc(
File "/home/gene/webhook/venv/lib/python3.10/site-packages/google/api_core/gapic_v1/method.py", line 113, in __call__
return wrapped_func(*args, **kwargs)
File "/home/gene/webhook/venv/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 74, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.ServiceUnavailable: 503 403:Forbidden
MarkEdmondson1234
Metadata
Metadata
Assignees
Labels
component:python sdkIssue/PR related to Python SDKIssue/PR related to Python SDKstatus:awaiting user responseAwaiting a response from the authorAwaiting a response from the authorstatus:staleIssue/PR will be closed automatically if there's no further activityIssue/PR will be closed automatically if there's no further activitytype:questionSupport-related issuesSupport-related issues