0

Deployment Logs Query

by
Published Oct 17, 2025

Query deployment logs. * Without timestamps (from/to) returns last `limit` messages (in last month). * With `from` only, returns first `limit` messages after `from` (inclusive). * With `to` only, returns last `limit` messages before `to` (inclusive). * With both `from` and `to`, return the first `limit` messages after `from`, but not later than `to`. * `from` and `to` should be no more than a month apart.

Script deep_infra Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Deepinfra = {
3
  token: string;
4
};
5
/**
6
 * Deployment Logs Query
7
 * Query deployment logs.
8
 * Without timestamps (from/to) returns last `limit` messages (in last month).
9
 * With `from` only, returns first `limit` messages after `from` (inclusive).
10
 * With `to` only, returns last `limit` messages before `to` (inclusive).
11
 * With both `from` and `to`, return the first `limit` messages after `from`, but not later than `to`.
12
 * `from` and `to` should be no more than a month apart.
13
 */
14
export async function main(
15
  auth: Deepinfra,
16
  deploy_id: string | undefined,
17
  pod_name: string | undefined,
18
  from: string | undefined,
19
  to: string | undefined,
20
  limit: string | undefined,
21
) {
22
  const url = new URL(`https://api.deepinfra.com/v1/deployment_logs/query`);
23
  for (const [k, v] of [
24
    ["deploy_id", deploy_id],
25
    ["pod_name", pod_name],
26
    ["from", from],
27
    ["to", to],
28
    ["limit", limit],
29
  ]) {
30
    if (v !== undefined && v !== "" && k !== undefined) {
31
      url.searchParams.append(k, v);
32
    }
33
  }
34
  const response = await fetch(url, {
35
    method: "GET",
36
    headers: {
37
      Authorization: "Bearer " + auth.token,
38
    },
39
    body: undefined,
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47