A TypeScript client library for interacting with the Prompteus Neuron Runner API (aka. calling Neurons)
npm i @prompteus-ai/neuron-runner
For detailed documentation, visit:
import { Prompteus } from '@prompteus-ai/neuron-runner';
// Create a client instance
const client = new Prompteus({
jwtOrApiKey: 'your-jwt-token', // Optional
baseURL: 'https://run.prompteus.com' // Optional, defaults to this value
});
// Call a neuron
try {
const response = await client.callNeuron('your-org', 'your-neuron', {
input: 'Hello, world!',
rawOutput: false, // Optional, defaults to false
bypassCache: false, // Optional, defaults to false
headers: {} // Optional, additional headers
});
console.log(response);
} catch (error) {
console.error(error);
}
The JWT token or API key can be provided in multiple ways:
- During client creation:
const client = new Prompteus({ jwtOrApiKey: 'your-token' });
- Using the setter method:
client.setJwtOrApiKey('your-token');
- Per request in the options:
await client.callNeuron('org', 'neuron', {
jwtOrApiKey: 'your-token'
});
Note: Authentication is not required if the neuron has public access enabled. See Access Control Documentation for more details.
constructor(options?: PrompteusOptions)
Options:
jwtOrApiKey?: string
- JWT token or API key for authenticationbaseURL?: string
- Base URL for the Prompteus API (defaults to "https://run.prompteus.com")
setJwtOrApiKey(jwtOrApiKey: string): void
Sets the JWT token or API key for all subsequent requests.
callNeuron(
organizationSlug: string,
neuronSlug: string,
options?: CallNeuronOptions
): Promise<NeuronSuccessResponse | string>
Options:
input?: string
- Input text for the neuron (defaults to empty string)rawOutput?: boolean
- Whether to return raw text output (defaults to false)bypassCache?: boolean
- Whether to bypass caching (defaults to false)headers?: Record<string, string>
- Additional headers to include, usually not required if using the default Prompteus APIjwtOrApiKey?: string
- JWT token or API key for this specific request
# Install dependencies
npm install
# Build the package
npm run build
# Format code
npm run format
MIT