You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: LICENSE
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Copyright 2025 dedalus
1
+
Copyright 2025 Dedalus
2
2
3
3
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copy file name to clipboardExpand all lines: README.md
+91-16Lines changed: 91 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainless.com/).
11
11
12
12
## Documentation
13
13
14
-
The full API of this library can be found in [api.md](api.md).
14
+
The REST API documentation can be found on [docs.dedaluslabs.ai](https://docs.dedaluslabs.ai). The full API of this library can be found in [api.md](api.md).
15
15
16
16
## Installation
17
17
@@ -30,18 +30,20 @@ from dedalus_labs import Dedalus
30
30
31
31
client = Dedalus(
32
32
api_key=os.environ.get("DEDALUS_API_KEY"), # This is the default and can be omitted
33
+
# or 'production' | 'development'; defaults to "production".
34
+
environment="staging",
33
35
)
34
36
35
-
completion= client.chat.create(
36
-
input=[
37
+
stream_chunk= client.chat.completions.create(
38
+
messages=[
37
39
{
38
40
"role": "user",
39
-
"content": "You are Stephen Dedalus. Respond in morose Joycean malaise.",
41
+
"content": "Hello, how are you today?",
40
42
}
41
43
],
42
-
model="gpt-4o-mini",
44
+
model="openai/gpt-5",
43
45
)
44
-
print(completion.id)
46
+
print(stream_chunk.id)
45
47
```
46
48
47
49
While you can provide an `api_key` keyword argument,
@@ -60,20 +62,22 @@ from dedalus_labs import AsyncDedalus
60
62
61
63
client = AsyncDedalus(
62
64
api_key=os.environ.get("DEDALUS_API_KEY"), # This is the default and can be omitted
65
+
# or 'production' | 'development'; defaults to "production".
"content": "You are Stephen Dedalus. Respond in morose Joycean malaise.",
116
+
"content": "Hello, how are you today?",
113
117
}
114
118
],
115
-
model="gpt-4o-mini",
119
+
model="openai/gpt-5",
116
120
)
117
-
print(completion.id)
121
+
print(stream_chunk.id)
118
122
119
123
120
124
asyncio.run(main())
121
125
```
122
126
127
+
## Streaming responses
128
+
129
+
We provide support for streaming responses using Server Side Events (SSE).
130
+
131
+
```python
132
+
from dedalus_labs import Dedalus
133
+
134
+
client = Dedalus()
135
+
136
+
stream = client.chat.completions.create(
137
+
stream=True,
138
+
messages=[
139
+
{
140
+
"role": "system",
141
+
"content": "You are Stephen Dedalus. Respond in morose Joycean malaise.",
142
+
},
143
+
{
144
+
"role": "user",
145
+
"content": "What do you think of artificial intelligence?",
146
+
},
147
+
],
148
+
model="openai/gpt-5",
149
+
)
150
+
for stream_chunk in stream:
151
+
print(stream_chunk.id)
152
+
```
153
+
154
+
The async client uses the exact same interface.
155
+
156
+
```python
157
+
from dedalus_labs import AsyncDedalus
158
+
159
+
client = AsyncDedalus()
160
+
161
+
stream =await client.chat.completions.create(
162
+
stream=True,
163
+
messages=[
164
+
{
165
+
"role": "system",
166
+
"content": "You are Stephen Dedalus. Respond in morose Joycean malaise.",
167
+
},
168
+
{
169
+
"role": "user",
170
+
"content": "What do you think of artificial intelligence?",
171
+
},
172
+
],
173
+
model="openai/gpt-5",
174
+
)
175
+
asyncfor stream_chunk in stream:
176
+
print(stream_chunk.id)
177
+
```
178
+
123
179
## Using types
124
180
125
181
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -218,6 +274,25 @@ On timeout, an `APITimeoutError` is thrown.
218
274
219
275
Note that requests that time out are [retried twice by default](#retries).
220
276
277
+
## Default Headers
278
+
279
+
We automatically send the following headers with all requests.
280
+
281
+
| Header | Value |
282
+
| --------------- | ------------- |
283
+
|`User-Agent`|`Dedalus-SDK`|
284
+
|`X-SDK-Version`|`1.0.0`|
285
+
286
+
If you need to, you can override these headers by setting default headers per-request or on the client object.
0 commit comments