@@ -26,7 +26,9 @@ const client = new BrowserUse({
2626 apiKey: process .env [' BROWSER_USE_API_KEY' ], // This is the default and can be omitted
2727});
2828
29- const task = await client .tasks .create ({ task: ' x' });
29+ const task = await client .tasks .create ({
30+ task: ' Search for the top 10 Hacker News posts and return the title and url.' ,
31+ });
3032
3133console .log (task .id );
3234```
@@ -43,7 +45,9 @@ const client = new BrowserUse({
4345 apiKey: process .env [' BROWSER_USE_API_KEY' ], // This is the default and can be omitted
4446});
4547
46- const params: BrowserUse .TaskCreateParams = { task: ' x' };
48+ const params: BrowserUse .TaskCreateParams = {
49+ task: ' Search for the top 10 Hacker News posts and return the title and url.' ,
50+ };
4751const task: BrowserUse .TaskCreateResponse = await client .tasks .create (params );
4852```
4953
@@ -57,15 +61,17 @@ a subclass of `APIError` will be thrown:
5761
5862<!-- prettier-ignore -->
5963``` ts
60- const task = await client .tasks .create ({ task: ' x' }).catch (async (err ) => {
61- if (err instanceof BrowserUse .APIError ) {
62- console .log (err .status ); // 400
63- console .log (err .name ); // BadRequestError
64- console .log (err .headers ); // {server: 'nginx', ...}
65- } else {
66- throw err ;
67- }
68- });
64+ const task = await client .tasks
65+ .create ({ task: ' Search for the top 10 Hacker News posts and return the title and url.' })
66+ .catch (async (err ) => {
67+ if (err instanceof BrowserUse .APIError ) {
68+ console .log (err .status ); // 400
69+ console .log (err .name ); // BadRequestError
70+ console .log (err .headers ); // {server: 'nginx', ...}
71+ } else {
72+ throw err ;
73+ }
74+ });
6975```
7076
7177Error codes are as follows:
@@ -97,7 +103,7 @@ const client = new BrowserUse({
97103});
98104
99105// Or, configure per-request:
100- await client .tasks .create ({ task: ' x ' }, {
106+ await client .tasks .create ({ task: ' Search for the top 10 Hacker News posts and return the title and url. ' }, {
101107 maxRetries: 5 ,
102108});
103109```
@@ -114,7 +120,7 @@ const client = new BrowserUse({
114120});
115121
116122// Override per-request:
117- await client .tasks .create ({ task: ' x ' }, {
123+ await client .tasks .create ({ task: ' Search for the top 10 Hacker News posts and return the title and url. ' }, {
118124 timeout: 5 * 1000 ,
119125});
120126```
@@ -137,11 +143,15 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
137143``` ts
138144const client = new BrowserUse ();
139145
140- const response = await client .tasks .create ({ task: ' x' }).asResponse ();
146+ const response = await client .tasks
147+ .create ({ task: ' Search for the top 10 Hacker News posts and return the title and url.' })
148+ .asResponse ();
141149console .log (response .headers .get (' X-My-Header' ));
142150console .log (response .statusText ); // access the underlying Response object
143151
144- const { data : task, response : raw } = await client .tasks .create ({ task: ' x' }).withResponse ();
152+ const { data : task, response : raw } = await client .tasks
153+ .create ({ task: ' Search for the top 10 Hacker News posts and return the title and url.' })
154+ .withResponse ();
145155console .log (raw .headers .get (' X-My-Header' ));
146156console .log (task .id );
147157```
0 commit comments