Skip to content

Commit 7b6ee51

Browse files
feat(api): api update
1 parent 167b11e commit 7b6ee51

10 files changed

Lines changed: 393 additions & 184 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 9
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer/unlayer-e87049219505c250c95423461c7fb7aa280a3238f98577973c687c1030da26bf.yml
3-
openapi_spec_hash: 613060b45d55c1ab27b70973e4402dfd
4-
config_hash: 2029dabcdae1b263de41e1a890ee90d8
1+
configured_endpoints: 10
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer/unlayer-35699cec89167aa9ce539f8008695911611f8bdf923234ed701ee3dbc0c5bcd2.yml
3+
openapi_spec_hash: 2ec4eef9500ac0007e1740f431835931
4+
config_hash: 20e7fbba9d423291aaf676f6a629dcaf

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ from unlayer.types.templates import GenerateCreateResponse
5858
Methods:
5959

6060
- <code title="post /v3/templates/generate">client.templates.generate.<a href="./src/unlayer/resources/templates/generate.py">create</a>(\*\*<a href="src/unlayer/types/templates/generate_create_params.py">params</a>) -> <a href="./src/unlayer/types/templates/generate_create_response.py">GenerateCreateResponse</a></code>
61+
- <code title="get /v3/templates/generate">client.templates.generate.<a href="./src/unlayer/resources/templates/generate.py">retrieve</a>() -> None</code>
6162

6263
## Import
6364

src/unlayer/resources/templates/generate.py

Lines changed: 101 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
from __future__ import annotations
44

55
from typing import Iterable
6-
from typing_extensions import Literal
76

87
import httpx
98

10-
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
9+
from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given
1110
from ..._utils import maybe_transform, async_maybe_transform
1211
from ..._compat import cached_property
1312
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -25,10 +24,6 @@
2524

2625

2726
class GenerateResource(SyncAPIResource):
28-
"""
29-
Template management — list, retrieve, generate, import, export, and convert designs.
30-
"""
31-
3227
@cached_property
3328
def with_raw_response(self) -> GenerateResourceWithRawResponse:
3429
"""
@@ -51,37 +46,45 @@ def with_streaming_response(self) -> GenerateResourceWithStreamingResponse:
5146
def create(
5247
self,
5348
*,
54-
display_mode: Literal["email", "web", "popup", "document"],
55-
input: Iterable[generate_create_params.Input],
49+
messages: Iterable[generate_create_params.Message],
5650
output: generate_create_params.Output,
5751
project_id: str | Omit = omit,
5852
context: generate_create_params.Context | Omit = omit,
59-
model: Literal["anthropic/claude-opus-4-6", "openai/gpt-5.2"] | Omit = omit,
53+
conversation_id: str | Omit = omit,
54+
locale: str | Omit = omit,
55+
model: str | Omit = omit,
6056
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6157
# The extra values given here take precedence over values defined on the client or passed to this method.
6258
extra_headers: Headers | None = None,
6359
extra_query: Query | None = None,
6460
extra_body: Body | None = None,
6561
timeout: float | httpx.Timeout | None | NotGiven = not_given,
6662
) -> GenerateCreateResponse:
67-
"""Generate, modify, or import an Unlayer design using AI.
63+
"""Generate or modify an Unlayer design using AI.
6864
69-
Provide typed input
70-
parts to describe what to generate.
65+
Send the conversation as
66+
`messages` (today only the last user message is consumed; earlier turns are
67+
accepted as chat history) and describe the target with `output.kind` +
68+
`output.displayMode`. Pass the current canvas state in `context` (full design
69+
JSON + selection pointer) to modify an existing design. Only `anthropic` and
70+
`openai` models are supported. To import existing HTML or an image instead, use
71+
POST /v3/templates/import.
7172
7273
Args:
73-
display_mode: Display mode for the design
74-
75-
input: Array of typed input parts (max 50)
76-
77-
output: What to generate
74+
messages: Conversation messages in chronological order, capped at 10 messages. The last
75+
`user` message is the prompt for this turn; any earlier `user`/`assistant` text
76+
turns are forwarded to the model as prior chat context. A `user` message may
77+
carry a predefined prompt action via `metadata.action.id` (e.g. SPELLING,
78+
REPHRASE).
7879
7980
project_id: The project ID (required for PAT auth, auto-resolved for API key auth)
8081
81-
context: Editor environment context
82+
conversation_id: Reserved for future server-side conversation memory.
8283
83-
model: AI model to use, in provider/model format. Optional — defaults to
84-
anthropic/claude-opus-4-6.
84+
locale: BCP-47 fallback locale for AI status messages.
85+
86+
model: AI model in "provider/id" form, e.g. "anthropic/claude-opus-4-7". Optional —
87+
server resolves a default per output kind.
8588
8689
extra_headers: Send extra headers
8790
@@ -95,10 +98,11 @@ def create(
9598
"/v3/templates/generate",
9699
body=maybe_transform(
97100
{
98-
"display_mode": display_mode,
99-
"input": input,
101+
"messages": messages,
100102
"output": output,
101103
"context": context,
104+
"conversation_id": conversation_id,
105+
"locale": locale,
102106
"model": model,
103107
},
104108
generate_create_params.GenerateCreateParams,
@@ -113,12 +117,27 @@ def create(
113117
cast_to=GenerateCreateResponse,
114118
)
115119

120+
def retrieve(
121+
self,
122+
*,
123+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
124+
# The extra values given here take precedence over values defined on the client or passed to this method.
125+
extra_headers: Headers | None = None,
126+
extra_query: Query | None = None,
127+
extra_body: Body | None = None,
128+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
129+
) -> None:
130+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
131+
return self._get(
132+
"/v3/templates/generate",
133+
options=make_request_options(
134+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
135+
),
136+
cast_to=NoneType,
137+
)
116138

117-
class AsyncGenerateResource(AsyncAPIResource):
118-
"""
119-
Template management — list, retrieve, generate, import, export, and convert designs.
120-
"""
121139

140+
class AsyncGenerateResource(AsyncAPIResource):
122141
@cached_property
123142
def with_raw_response(self) -> AsyncGenerateResourceWithRawResponse:
124143
"""
@@ -141,37 +160,45 @@ def with_streaming_response(self) -> AsyncGenerateResourceWithStreamingResponse:
141160
async def create(
142161
self,
143162
*,
144-
display_mode: Literal["email", "web", "popup", "document"],
145-
input: Iterable[generate_create_params.Input],
163+
messages: Iterable[generate_create_params.Message],
146164
output: generate_create_params.Output,
147165
project_id: str | Omit = omit,
148166
context: generate_create_params.Context | Omit = omit,
149-
model: Literal["anthropic/claude-opus-4-6", "openai/gpt-5.2"] | Omit = omit,
167+
conversation_id: str | Omit = omit,
168+
locale: str | Omit = omit,
169+
model: str | Omit = omit,
150170
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
151171
# The extra values given here take precedence over values defined on the client or passed to this method.
152172
extra_headers: Headers | None = None,
153173
extra_query: Query | None = None,
154174
extra_body: Body | None = None,
155175
timeout: float | httpx.Timeout | None | NotGiven = not_given,
156176
) -> GenerateCreateResponse:
157-
"""Generate, modify, or import an Unlayer design using AI.
177+
"""Generate or modify an Unlayer design using AI.
158178
159-
Provide typed input
160-
parts to describe what to generate.
179+
Send the conversation as
180+
`messages` (today only the last user message is consumed; earlier turns are
181+
accepted as chat history) and describe the target with `output.kind` +
182+
`output.displayMode`. Pass the current canvas state in `context` (full design
183+
JSON + selection pointer) to modify an existing design. Only `anthropic` and
184+
`openai` models are supported. To import existing HTML or an image instead, use
185+
POST /v3/templates/import.
161186
162187
Args:
163-
display_mode: Display mode for the design
164-
165-
input: Array of typed input parts (max 50)
166-
167-
output: What to generate
188+
messages: Conversation messages in chronological order, capped at 10 messages. The last
189+
`user` message is the prompt for this turn; any earlier `user`/`assistant` text
190+
turns are forwarded to the model as prior chat context. A `user` message may
191+
carry a predefined prompt action via `metadata.action.id` (e.g. SPELLING,
192+
REPHRASE).
168193
169194
project_id: The project ID (required for PAT auth, auto-resolved for API key auth)
170195
171-
context: Editor environment context
196+
conversation_id: Reserved for future server-side conversation memory.
197+
198+
locale: BCP-47 fallback locale for AI status messages.
172199
173-
model: AI model to use, in provider/model format. Optional — defaults to
174-
anthropic/claude-opus-4-6.
200+
model: AI model in "provider/id" form, e.g. "anthropic/claude-opus-4-7". Optional —
201+
server resolves a default per output kind.
175202
176203
extra_headers: Send extra headers
177204
@@ -185,10 +212,11 @@ async def create(
185212
"/v3/templates/generate",
186213
body=await async_maybe_transform(
187214
{
188-
"display_mode": display_mode,
189-
"input": input,
215+
"messages": messages,
190216
"output": output,
191217
"context": context,
218+
"conversation_id": conversation_id,
219+
"locale": locale,
192220
"model": model,
193221
},
194222
generate_create_params.GenerateCreateParams,
@@ -205,6 +233,25 @@ async def create(
205233
cast_to=GenerateCreateResponse,
206234
)
207235

236+
async def retrieve(
237+
self,
238+
*,
239+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
240+
# The extra values given here take precedence over values defined on the client or passed to this method.
241+
extra_headers: Headers | None = None,
242+
extra_query: Query | None = None,
243+
extra_body: Body | None = None,
244+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
245+
) -> None:
246+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
247+
return await self._get(
248+
"/v3/templates/generate",
249+
options=make_request_options(
250+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
251+
),
252+
cast_to=NoneType,
253+
)
254+
208255

209256
class GenerateResourceWithRawResponse:
210257
def __init__(self, generate: GenerateResource) -> None:
@@ -213,6 +260,9 @@ def __init__(self, generate: GenerateResource) -> None:
213260
self.create = to_raw_response_wrapper(
214261
generate.create,
215262
)
263+
self.retrieve = to_raw_response_wrapper(
264+
generate.retrieve,
265+
)
216266

217267

218268
class AsyncGenerateResourceWithRawResponse:
@@ -222,6 +272,9 @@ def __init__(self, generate: AsyncGenerateResource) -> None:
222272
self.create = async_to_raw_response_wrapper(
223273
generate.create,
224274
)
275+
self.retrieve = async_to_raw_response_wrapper(
276+
generate.retrieve,
277+
)
225278

226279

227280
class GenerateResourceWithStreamingResponse:
@@ -231,6 +284,9 @@ def __init__(self, generate: GenerateResource) -> None:
231284
self.create = to_streamed_response_wrapper(
232285
generate.create,
233286
)
287+
self.retrieve = to_streamed_response_wrapper(
288+
generate.retrieve,
289+
)
234290

235291

236292
class AsyncGenerateResourceWithStreamingResponse:
@@ -240,3 +296,6 @@ def __init__(self, generate: AsyncGenerateResource) -> None:
240296
self.create = async_to_streamed_response_wrapper(
241297
generate.create,
242298
)
299+
self.retrieve = async_to_streamed_response_wrapper(
300+
generate.retrieve,
301+
)

src/unlayer/resources/templates/import_.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def create(
5454
display_mode: Literal["email", "web", "popup", "document"],
5555
input: Iterable[import_create_params.Input],
5656
project_id: str | Omit = omit,
57-
model: Literal["anthropic/claude-opus-4-6", "openai/gpt-5.2"] | Omit = omit,
57+
model: str | Omit = omit,
5858
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5959
# The extra values given here take precedence over values defined on the client or passed to this method.
6060
extra_headers: Headers | None = None,
@@ -74,8 +74,11 @@ def create(
7474
7575
project_id: The project ID (required for PAT auth, auto-resolved for API key auth)
7676
77-
model: AI model to use, in provider/model format. Optional — defaults to
78-
anthropic/claude-opus-4-6.
77+
model: AI model to use. Accepts a provider/model string (e.g.
78+
"anthropic/claude-opus-4-7", "openai/gpt-5.5"), a bare provider ("anthropic",
79+
"openai") which uses that provider's default model, or a bare model id
80+
("claude-opus-4-7", "gpt-5.5") with the provider inferred from the name.
81+
Optional — defaults to anthropic/claude-opus-4-7.
7982
8083
extra_headers: Send extra headers
8184
@@ -136,7 +139,7 @@ async def create(
136139
display_mode: Literal["email", "web", "popup", "document"],
137140
input: Iterable[import_create_params.Input],
138141
project_id: str | Omit = omit,
139-
model: Literal["anthropic/claude-opus-4-6", "openai/gpt-5.2"] | Omit = omit,
142+
model: str | Omit = omit,
140143
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
141144
# The extra values given here take precedence over values defined on the client or passed to this method.
142145
extra_headers: Headers | None = None,
@@ -156,8 +159,11 @@ async def create(
156159
157160
project_id: The project ID (required for PAT auth, auto-resolved for API key auth)
158161
159-
model: AI model to use, in provider/model format. Optional — defaults to
160-
anthropic/claude-opus-4-6.
162+
model: AI model to use. Accepts a provider/model string (e.g.
163+
"anthropic/claude-opus-4-7", "openai/gpt-5.5"), a bare provider ("anthropic",
164+
"openai") which uses that provider's default model, or a bare model id
165+
("claude-opus-4-7", "gpt-5.5") with the provider inferred from the name.
166+
Optional — defaults to anthropic/claude-opus-4-7.
161167
162168
extra_headers: Send extra headers
163169

src/unlayer/resources/templates/templates.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ def convert_simple_to_full(self) -> ConvertSimpleToFullResource:
7878

7979
@cached_property
8080
def generate(self) -> GenerateResource:
81-
"""
82-
Template management — list, retrieve, generate, import, export, and convert designs.
83-
"""
8481
return GenerateResource(self._client)
8582

8683
@cached_property
@@ -232,9 +229,6 @@ def convert_simple_to_full(self) -> AsyncConvertSimpleToFullResource:
232229

233230
@cached_property
234231
def generate(self) -> AsyncGenerateResource:
235-
"""
236-
Template management — list, retrieve, generate, import, export, and convert designs.
237-
"""
238232
return AsyncGenerateResource(self._client)
239233

240234
@cached_property
@@ -394,9 +388,6 @@ def convert_simple_to_full(self) -> ConvertSimpleToFullResourceWithRawResponse:
394388

395389
@cached_property
396390
def generate(self) -> GenerateResourceWithRawResponse:
397-
"""
398-
Template management — list, retrieve, generate, import, export, and convert designs.
399-
"""
400391
return GenerateResourceWithRawResponse(self._templates.generate)
401392

402393
@cached_property
@@ -434,9 +425,6 @@ def convert_simple_to_full(self) -> AsyncConvertSimpleToFullResourceWithRawRespo
434425

435426
@cached_property
436427
def generate(self) -> AsyncGenerateResourceWithRawResponse:
437-
"""
438-
Template management — list, retrieve, generate, import, export, and convert designs.
439-
"""
440428
return AsyncGenerateResourceWithRawResponse(self._templates.generate)
441429

442430
@cached_property
@@ -474,9 +462,6 @@ def convert_simple_to_full(self) -> ConvertSimpleToFullResourceWithStreamingResp
474462

475463
@cached_property
476464
def generate(self) -> GenerateResourceWithStreamingResponse:
477-
"""
478-
Template management — list, retrieve, generate, import, export, and convert designs.
479-
"""
480465
return GenerateResourceWithStreamingResponse(self._templates.generate)
481466

482467
@cached_property
@@ -514,9 +499,6 @@ def convert_simple_to_full(self) -> AsyncConvertSimpleToFullResourceWithStreamin
514499

515500
@cached_property
516501
def generate(self) -> AsyncGenerateResourceWithStreamingResponse:
517-
"""
518-
Template management — list, retrieve, generate, import, export, and convert designs.
519-
"""
520502
return AsyncGenerateResourceWithStreamingResponse(self._templates.generate)
521503

522504
@cached_property

0 commit comments

Comments
 (0)