@@ -25,18 +25,18 @@ pip install writer-sdk
2525Before you begin, ensure you have:
2626
2727- Python 3.8 or higher
28- - A [ Writer API key] ( https://dev.writer.com/api-guides/introduction#authentication )
28+ - A [ Writer API key] ( https://dev.writer.com/api-guides/quickstart#generate-a-new-api-key )
2929
3030## Authentication
3131
3232To authenticate with the Writer API, set the ` WRITER_API_KEY ` environment variable.
3333
34- The ` Writer ` class automatically infers your API key from the ` WRITER_API_KEY ` environment variable.
35-
3634``` shell
3735$ export WRITER_API_KEY=" my-api-key"
3836```
3937
38+ The ` Writer ` class automatically infers your API key from the ` WRITER_API_KEY ` environment variable.
39+
4040``` python
4141from writerai import Writer
4242
@@ -127,12 +127,14 @@ stream = client.chat.chat(
127127 model = " palmyra-x-004" ,
128128 stream = True ,
129129)
130+
130131output_text = " "
131- for chunk in chat_response :
132+ for chunk in stream :
132133 if chunk.choices[0 ].delta.content:
133- output_text += chunk.choices[0 ].delta.content:
134+ output_text += chunk.choices[0 ].delta.content
134135 else :
135136 continue
137+ print (output_text)
136138```
137139
138140The async client uses the same interface.
@@ -153,12 +155,14 @@ stream = await client.chat.chat(
153155 model = " palmyra-x-004" ,
154156 stream = True ,
155157)
158+
156159output_text = " "
157160async for chunk in stream:
158161 if chunk.choices[0 ].delta.content:
159162 output_text += chunk.choices[0 ].delta.content
160163 else :
161164 continue
165+ print (output_text)
162166```
163167
164168For non-streaming responses, the library returns a single response object.
@@ -307,6 +311,7 @@ By default, requests time out after three minutes. You can configure this with a
307311which accepts a float or an [ ` httpx.Timeout ` ] ( https://www.python-httpx.org/advanced/#fine-tuning-the-configuration ) object:
308312
309313``` python
314+ import httpx
310315from writerai import Writer
311316
312317# Configure the default for all requests:
0 commit comments