Skip to content

Commit d64d811

Browse files
build: Use CI environment for examples API key (#3394)
1 parent a526ee8 commit d64d811

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
examples:
101101
timeout-minutes: 10
102102
name: examples
103+
environment: ci
103104
runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
104105
if: github.repository == 'openai/openai-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
105106

examples/async_demo.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@
99

1010

1111
async def main() -> None:
12-
stream = await client.completions.create(
13-
model="gpt-3.5-turbo-instruct",
14-
prompt="Say this is a test",
12+
stream = await client.chat.completions.create(
13+
model="gpt-5.5",
14+
messages=[
15+
{
16+
"role": "user",
17+
"content": "Say this is a test",
18+
},
19+
],
1520
stream=True,
1621
)
17-
async for completion in stream:
18-
print(completion.choices[0].text, end="")
22+
async for chunk in stream:
23+
if not chunk.choices:
24+
continue
25+
26+
print(chunk.choices[0].delta.content, end="")
1927
print()
2028

2129

examples/demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Non-streaming:
99
print("----- standard request -----")
1010
completion = client.chat.completions.create(
11-
model="gpt-4",
11+
model="gpt-5.5",
1212
messages=[
1313
{
1414
"role": "user",
@@ -21,7 +21,7 @@
2121
# Streaming:
2222
print("----- streaming request -----")
2323
stream = client.chat.completions.create(
24-
model="gpt-4",
24+
model="gpt-5.5",
2525
messages=[
2626
{
2727
"role": "user",
@@ -40,7 +40,7 @@
4040
# Response headers:
4141
print("----- custom response headers test -----")
4242
response = client.chat.completions.with_raw_response.create(
43-
model="gpt-4",
43+
model="gpt-5.5",
4444
messages=[
4545
{
4646
"role": "user",

0 commit comments

Comments
 (0)