Skip to content

Commit dba2c80

Browse files
committed
fix: url versions and tokens
1 parent 562675a commit dba2c80

File tree

8 files changed

+19
-24
lines changed

8 files changed

+19
-24
lines changed

examples/0-api-key.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function main() {
1212
// Initialize the client in API key mode
1313
// For sandbox, use the following:
1414
const client = new NilaiOpenAIClient({
15-
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
15+
baseURL: "https://nilai-a779.nillion.network/v1/",
1616
apiKey: API_KEY,
1717
nilauthInstance: NilAuthInstance.SANDBOX,
1818
// For production, use the following:
@@ -21,7 +21,7 @@ async function main() {
2121

2222
// Make a request to the Nilai API
2323
const response = await client.chat.completions.create({
24-
model: "meta-llama/Llama-3.2-3B-Instruct",
24+
model: "google/gemma-3-27b-it",
2525
messages: [
2626
{ role: "user", content: "Hello! Can you help me with something?" }
2727
],

examples/1-delegation-token.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,16 @@ async function main() {
2929
expirationTime: 10, // 10 seconds validity of delegation tokens
3030
tokenMaxUses: 1, // 1 use of a delegation token
3131
},
32-
// For production instances, use the following:
33-
// NilAuthInstance.PRODUCTION,
3432
);
3533

3634
// >>> Client initializes a client
3735
// The client is responsible for making requests to the Nilai API.
3836
// We do not provide an API key but we set the auth type to DELEGATION_TOKEN
3937
const client = new NilaiOpenAIClient({
40-
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
38+
baseURL: "https://nilai-a779.nillion.network/v1/",
4139
authType: AuthType.DELEGATION_TOKEN,
4240
// For production instances, use the following:
43-
// nilauthInstance: NilAuthInstance.PRODUCTION,
41+
//nilauthInstance: NilAuthInstance.PRODUCTION,
4442
});
4543

4644
// >>> Client produces a delegation request
@@ -56,7 +54,7 @@ async function main() {
5654

5755
// >>> Client uses the delegation token to make a request
5856
const response = await client.chat.completions.create({
59-
model: "meta-llama/Llama-3.2-3B-Instruct",
57+
model: "google/gemma-3-27b-it",
6058
messages: [
6159
{ role: "user", content: "Hello! Can you help me with something?" }
6260
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nillion/nilai-ts",
3-
"version": "0.0.0-alpha.3",
3+
"version": "0.0.0-alpha.4",
44
"description": "Nilai Typescript SDK",
55
"type": "module",
66
"main": "dist/index.js",

src/server.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
type DelegationTokenResponse,
1515
type DelegationServerConfig,
1616
DefaultDelegationTokenServerConfig,
17-
NilAuthInstance,
1817
RequestType,
1918
} from "./types";
2019

@@ -23,17 +22,14 @@ import { hexToBytes, isExpired } from "./utils";
2322
export class DelegationTokenServer {
2423
private config: DelegationServerConfig;
2524
private nilAuthPrivateKey: Keypair;
26-
private nilAuthInstance: NilAuthInstance;
2725
private _rootTokenEnvelope: NucTokenEnvelope | null = null;
2826

2927
constructor(
3028
privateKey: string,
3129
config: DelegationServerConfig = DefaultDelegationTokenServerConfig,
32-
nilAuthInstance: NilAuthInstance = NilAuthInstance.SANDBOX,
3330
) {
3431
this.config = config;
3532
this.nilAuthPrivateKey = Keypair.from(privateKey);
36-
this.nilAuthInstance = nilAuthInstance;
3733
}
3834

3935
/**
@@ -47,7 +43,7 @@ export class DelegationTokenServer {
4743

4844
if (!this._rootTokenEnvelope || isExpired(this._rootTokenEnvelope)) {
4945
const nilauthClient = await NilauthClient.from(
50-
this.nilAuthInstance,
46+
this.config.nilauthInstance,
5147
await new PayerBuilder()
5248
.chainUrl("https://rpc.testnet.nilchain-rpc-proxy.nilogy.xyz")
5349
.keypair(this.nilAuthPrivateKey)

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type AuthType = z.infer<typeof AuthTypeSchema>;
1313

1414
export const NilAuthInstance = {
1515
SANDBOX: "https://nilauth.sandbox.app-cluster.sandbox.nilogy.xyz" as const,
16-
PRODUCTION: "https://nilauth.nillion.network" as const,
16+
PRODUCTION: "https://nilauth-cf7f.nillion.network" as const,
1717
} as const;
1818

1919
export const NilAuthInstanceSchema = z.nativeEnum(NilAuthInstance);

tests/client.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("NilaiOpenAIClient", () => {
1111

1212
beforeEach(() => {
1313
client = new NilaiOpenAIClient({
14-
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
14+
baseURL: "https://nilai-a779.nillion.network/v1/",
1515
apiKey: process.env.NILLION_API_KEY || "",
1616
});
1717
});
@@ -20,7 +20,7 @@ describe("NilaiOpenAIClient", () => {
2020
it("should add authorization header via prepareRequest", async () => {
2121
try {
2222
const _completion = await client.chat.completions.create({
23-
model: "meta-llama/Llama-3.1-8B-Instruct",
23+
model: "google/gemma-3-27b-it",
2424
messages: [
2525
{ role: "system", content: "Talk like a pirate." },
2626
{ role: "user", content: "Are semicolons optional in JavaScript?" },
@@ -176,9 +176,10 @@ describe("authentication modes", () => {
176176
beforeEach(() => {
177177
client = new NilaiOpenAIClient({
178178
authType: AuthType.API_KEY,
179-
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
179+
baseURL: "https://nilai-a779.nillion.network/v1/",
180180
apiKey:
181-
"c2b961027b26c38824bdc2eccf9cdada6646d1b87c665ddf235c33a57335bd47",
181+
process.env.NILLION_API_KEY ||
182+
"Nillion2025", // Use a default key for testing purposes
182183
});
183184
});
184185

@@ -222,7 +223,7 @@ describe("OpenAI", () => {
222223
it("should add authorization header via prepareRequest", async () => {
223224
try {
224225
const _completion = await client.chat.completions.create({
225-
model: "meta-llama/Llama-3.1-8B-Instruct",
226+
model: "google/gemma-3-27b-it",
226227
messages: [
227228
{ role: "system", content: "Talk like a pirate." },
228229
{ role: "user", content: "Are semicolons optional in JavaScript?" },
@@ -251,7 +252,7 @@ describe("newClient", () => {
251252
it("should add authorization header via prepareRequest", async () => {
252253
try {
253254
const _completion = await client.chat.completions.create({
254-
model: "meta-llama/Llama-3.1-8B-Instruct",
255+
model: "google/gemma-3-27b-it",
255256
messages: [
256257
{ role: "system", content: "Talk like a pirate." },
257258
{ role: "user", content: "Are semicolons optional in JavaScript?" },

tests/delegated_client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("NilaiOpenAIClient", () => {
77
beforeEach(() => {
88
client = new NilaiOpenAIClient({
99
//baseURL: "http://localhost:8088/v1/",
10-
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
10+
baseURL: "https://nilai-a779.nillion.network/v1/",
1111
apiKey: process.env.NILLION_API_KEY || "",
1212
});
1313
});
@@ -16,7 +16,7 @@ describe("NilaiOpenAIClient", () => {
1616
it("should add authorization header via prepareRequest", async () => {
1717
try {
1818
const _completion = await client.chat.completions.create({
19-
model: "meta-llama/Llama-3.2-3B-Instruct",
19+
model: "google/gemma-3-27b-it",
2020
messages: [
2121
{ role: "system", content: "Talk like a pirate." },
2222
{ role: "user", content: "Are semicolons optional in JavaScript?" },

tests/server.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("DelegationTokenServer", () => {
1010
beforeEach(() => {
1111
client = new NilaiOpenAIClient({
1212
// baseURL: "http://localhost:8088/v1/",
13-
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
13+
baseURL: "https://nilai-a779.nillion.network/v1/",
1414
authType: AuthType.DELEGATION_TOKEN,
1515
});
1616

@@ -30,7 +30,7 @@ describe("DelegationTokenServer", () => {
3030
client.updateDelegation(response);
3131

3232
const _completion = await client.chat.completions.create({
33-
model: "meta-llama/Llama-3.1-8B-Instruct",
33+
model: "google/gemma-3-27b-it",
3434
messages: [
3535
{ role: "system", content: "Talk like a pirate." },
3636
{ role: "user", content: "Are semicolons optional in JavaScript?" },

0 commit comments

Comments
 (0)