@blockrun/llm 1.10.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -151,6 +151,13 @@ The classifier runs in <1ms, 100% locally, and routes to one of four tiers:
151
151
 
152
152
  ## Available Models
153
153
 
154
+ ### OpenAI GPT-5.5 Family
155
+ Released 2026-04-23 — first fully retrained base since GPT-4.5. 1M context, 128K output, native agent + computer use.
156
+
157
+ | Model | Input Price | Output Price |
158
+ |-------|-------------|--------------|
159
+ | `openai/gpt-5.5` | $5.00/M | $30.00/M |
160
+
154
161
  ### OpenAI GPT-5.4 Family
155
162
  | Model | Input Price | Output Price |
156
163
  |-------|-------------|--------------|
package/dist/index.cjs CHANGED
@@ -1686,6 +1686,8 @@ var DEFAULT_API_URL2 = "https://blockrun.ai/api";
1686
1686
  var DEFAULT_MODEL = "google/nano-banana";
1687
1687
  var DEFAULT_SIZE = "1024x1024";
1688
1688
  var DEFAULT_TIMEOUT2 = 2e5;
1689
+ var POLL_INTERVAL_MS = 3e3;
1690
+ var POLL_MAX_DURATION_MS = 3e5;
1689
1691
  var ImageClient = class {
1690
1692
  account;
1691
1693
  privateKey;
@@ -1870,7 +1872,70 @@ var ImageClient = class {
1870
1872
  sanitizeErrorResponse(errorBody)
1871
1873
  );
1872
1874
  }
1873
- return retryResponse.json();
1875
+ const responseBody = await retryResponse.json();
1876
+ if (retryResponse.status === 202 || responseBody.status === "queued" || responseBody.status === "in_progress") {
1877
+ if (!responseBody.poll_url) {
1878
+ throw new APIError(
1879
+ `Server returned ${retryResponse.status} but no poll_url to follow.`,
1880
+ retryResponse.status,
1881
+ sanitizeErrorResponse(responseBody)
1882
+ );
1883
+ }
1884
+ return this.pollImageJob(responseBody.poll_url, paymentPayload);
1885
+ }
1886
+ return responseBody;
1887
+ }
1888
+ /**
1889
+ * Poll the async image generation endpoint until the job reaches a terminal
1890
+ * state (completed/failed). Used when the POST returns 202 + poll_url for
1891
+ * slow models that exceeded the server's inline window.
1892
+ *
1893
+ * Sends the SAME payment header on every poll — the server binds the payer
1894
+ * to the job id and re-verifies on each call. Settlement happens server-side
1895
+ * on the first poll where status=completed.
1896
+ */
1897
+ async pollImageJob(pollPath, paymentHeader) {
1898
+ const pollUrl = pollPath.startsWith("/api/") ? `${this.apiUrl.replace(/\/api$/, "")}${pollPath}` : `${this.apiUrl}${pollPath.startsWith("/") ? "" : "/"}${pollPath}`;
1899
+ const startedAt = Date.now();
1900
+ while (Date.now() - startedAt < POLL_MAX_DURATION_MS) {
1901
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
1902
+ const pollResp = await this.fetchWithTimeout(pollUrl, {
1903
+ method: "GET",
1904
+ headers: {
1905
+ "PAYMENT-SIGNATURE": paymentHeader,
1906
+ "X-PAYMENT": paymentHeader
1907
+ }
1908
+ });
1909
+ if (pollResp.status === 202) {
1910
+ continue;
1911
+ }
1912
+ const pollBody = await pollResp.json().catch(() => ({}));
1913
+ if (!pollResp.ok) {
1914
+ throw new APIError(
1915
+ `API error during poll: ${pollResp.status}`,
1916
+ pollResp.status,
1917
+ sanitizeErrorResponse(pollBody)
1918
+ );
1919
+ }
1920
+ if (pollBody.status === "failed") {
1921
+ throw new APIError(
1922
+ pollBody.error || "Upstream image generation failed",
1923
+ 200,
1924
+ sanitizeErrorResponse(pollBody)
1925
+ );
1926
+ }
1927
+ if (pollBody.data) {
1928
+ return pollBody;
1929
+ }
1930
+ if (pollBody.status === "queued" || pollBody.status === "in_progress") {
1931
+ continue;
1932
+ }
1933
+ }
1934
+ throw new APIError(
1935
+ `Image generation poll timed out after ${POLL_MAX_DURATION_MS / 1e3}s`,
1936
+ 504,
1937
+ { error: "poll_timeout", poll_url: pollPath }
1938
+ );
1874
1939
  }
1875
1940
  /**
1876
1941
  * Fetch with timeout.
package/dist/index.d.cts CHANGED
@@ -1195,6 +1195,16 @@ declare class ImageClient {
1195
1195
  * Handle 402 response: parse requirements, sign payment, retry.
1196
1196
  */
1197
1197
  private handlePaymentAndRetry;
1198
+ /**
1199
+ * Poll the async image generation endpoint until the job reaches a terminal
1200
+ * state (completed/failed). Used when the POST returns 202 + poll_url for
1201
+ * slow models that exceeded the server's inline window.
1202
+ *
1203
+ * Sends the SAME payment header on every poll — the server binds the payer
1204
+ * to the job id and re-verifies on each call. Settlement happens server-side
1205
+ * on the first poll where status=completed.
1206
+ */
1207
+ private pollImageJob;
1198
1208
  /**
1199
1209
  * Fetch with timeout.
1200
1210
  */
package/dist/index.d.ts CHANGED
@@ -1195,6 +1195,16 @@ declare class ImageClient {
1195
1195
  * Handle 402 response: parse requirements, sign payment, retry.
1196
1196
  */
1197
1197
  private handlePaymentAndRetry;
1198
+ /**
1199
+ * Poll the async image generation endpoint until the job reaches a terminal
1200
+ * state (completed/failed). Used when the POST returns 202 + poll_url for
1201
+ * slow models that exceeded the server's inline window.
1202
+ *
1203
+ * Sends the SAME payment header on every poll — the server binds the payer
1204
+ * to the job id and re-verifies on each call. Settlement happens server-side
1205
+ * on the first poll where status=completed.
1206
+ */
1207
+ private pollImageJob;
1198
1208
  /**
1199
1209
  * Fetch with timeout.
1200
1210
  */
package/dist/index.js CHANGED
@@ -1597,6 +1597,8 @@ var DEFAULT_API_URL2 = "https://blockrun.ai/api";
1597
1597
  var DEFAULT_MODEL = "google/nano-banana";
1598
1598
  var DEFAULT_SIZE = "1024x1024";
1599
1599
  var DEFAULT_TIMEOUT2 = 2e5;
1600
+ var POLL_INTERVAL_MS = 3e3;
1601
+ var POLL_MAX_DURATION_MS = 3e5;
1600
1602
  var ImageClient = class {
1601
1603
  account;
1602
1604
  privateKey;
@@ -1781,7 +1783,70 @@ var ImageClient = class {
1781
1783
  sanitizeErrorResponse(errorBody)
1782
1784
  );
1783
1785
  }
1784
- return retryResponse.json();
1786
+ const responseBody = await retryResponse.json();
1787
+ if (retryResponse.status === 202 || responseBody.status === "queued" || responseBody.status === "in_progress") {
1788
+ if (!responseBody.poll_url) {
1789
+ throw new APIError(
1790
+ `Server returned ${retryResponse.status} but no poll_url to follow.`,
1791
+ retryResponse.status,
1792
+ sanitizeErrorResponse(responseBody)
1793
+ );
1794
+ }
1795
+ return this.pollImageJob(responseBody.poll_url, paymentPayload);
1796
+ }
1797
+ return responseBody;
1798
+ }
1799
+ /**
1800
+ * Poll the async image generation endpoint until the job reaches a terminal
1801
+ * state (completed/failed). Used when the POST returns 202 + poll_url for
1802
+ * slow models that exceeded the server's inline window.
1803
+ *
1804
+ * Sends the SAME payment header on every poll — the server binds the payer
1805
+ * to the job id and re-verifies on each call. Settlement happens server-side
1806
+ * on the first poll where status=completed.
1807
+ */
1808
+ async pollImageJob(pollPath, paymentHeader) {
1809
+ const pollUrl = pollPath.startsWith("/api/") ? `${this.apiUrl.replace(/\/api$/, "")}${pollPath}` : `${this.apiUrl}${pollPath.startsWith("/") ? "" : "/"}${pollPath}`;
1810
+ const startedAt = Date.now();
1811
+ while (Date.now() - startedAt < POLL_MAX_DURATION_MS) {
1812
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
1813
+ const pollResp = await this.fetchWithTimeout(pollUrl, {
1814
+ method: "GET",
1815
+ headers: {
1816
+ "PAYMENT-SIGNATURE": paymentHeader,
1817
+ "X-PAYMENT": paymentHeader
1818
+ }
1819
+ });
1820
+ if (pollResp.status === 202) {
1821
+ continue;
1822
+ }
1823
+ const pollBody = await pollResp.json().catch(() => ({}));
1824
+ if (!pollResp.ok) {
1825
+ throw new APIError(
1826
+ `API error during poll: ${pollResp.status}`,
1827
+ pollResp.status,
1828
+ sanitizeErrorResponse(pollBody)
1829
+ );
1830
+ }
1831
+ if (pollBody.status === "failed") {
1832
+ throw new APIError(
1833
+ pollBody.error || "Upstream image generation failed",
1834
+ 200,
1835
+ sanitizeErrorResponse(pollBody)
1836
+ );
1837
+ }
1838
+ if (pollBody.data) {
1839
+ return pollBody;
1840
+ }
1841
+ if (pollBody.status === "queued" || pollBody.status === "in_progress") {
1842
+ continue;
1843
+ }
1844
+ }
1845
+ throw new APIError(
1846
+ `Image generation poll timed out after ${POLL_MAX_DURATION_MS / 1e3}s`,
1847
+ 504,
1848
+ { error: "poll_timeout", poll_url: pollPath }
1849
+ );
1785
1850
  }
1786
1851
  /**
1787
1852
  * Fetch with timeout.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/llm",
3
- "version": "1.10.1",
3
+ "version": "1.12.0",
4
4
  "type": "module",
5
5
  "description": "BlockRun SDK - Pay-per-request AI (LLM, Image, Video, Music) via x402 on Base and Solana",
6
6
  "main": "dist/index.cjs",