googleapis / googleapis/python-genai
System Instruction Error
- Dominant language
- Python
- Stars
- 4k
- Forks
- 1k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 40
Description
I kept trying this pattern:
```python
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content_stream(
model='gemini-2.0-flash',
contents='Tell me a story in 100 words.',
config=types.GenerateContentConfig(
system_instruction='you are a story teller for kids under 5 years old',
max_output_tokens= 400,
temperature= 0
)
)
```
but I got this error from the API non stop (Invalid JSON payload received. Unknown name \\"systemInstruction\\"):
```text
Error in stream_chat_response: API Error 400: b'{\n "error": {\n "code": 400,\n "message": "Invalid JSON payload received. Unknown name \\"systemInstruction\\": Cannot find field.",\n "status": "INVALID_ARGUMENT",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.BadRequest",\n "fieldViolations": [\n {\n "description": "Invalid JSON payload received. Unknown name \\"systemInstruction\\": Cannot find field."\n }\n ]\n }\n ]\n }\n}\n'
```
The old SDK works perfectly: https://github.com/google-gemini/generative-ai-python
Contributor guide
Assessment
This issue has not been assessed yet.