x-pack/platform/packages/shared/kbn-inference-cli/README.md
Exposes an Inference (plugin) API client for scripts, that mimicks the chatComplete
and output APIs that are available on its start contract. It depends on the KibanaClient
that is exposed from the @kbn/kibana-api-cli package. It automatically selects a
connector if available. Usage:
import { createInferenceClient } from '@kbn/inference-cli';
import { ToolingLog } from '@kbn/tooling-log';
const log = new ToolingLog();
const inferenceClient = await createInferenceClient({
log,
// pass in a signal that is triggered on teardown
signal: new AbortController().signal,
});
const response = await inferenceClient.output({
id: 'extract_personal_details',
input: `Sarah is a 29-year-old software developer living in San Francisco.`,
schema: {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'number' },
city: { type: 'string' },
},
required: ['name'],
} as const,
});
log.info(response.output);
Running a recipe:
yarn run ts-node x-pack/solutions/observability/packages/kbn-genai-cli/recipes/hello_world.ts
You can connect your local Elasticsearch to the Elastic Inference Service (EIS) using Cloud Connect (aka. Cloud Connected Mode, CCM) by running node scripts/eis.js. This script configures your local Elasticsearch instance to use a real EIS endpoint without needing to run EIS locally.
Elasticsearch: Start Elasticsearch with the EIS URL of the QA environment and an Enterprise trial license:
yarn es snapshot --license trial -E xpack.inference.elastic.url=https://inference.eu-west-1.aws.svc.qa.elastic.cloud
Vault Access: The script fetches the EIS API key from Vault. Make sure you are logged in:
VAULT_ADDR=https://secrets.elastic.co:8200 vault login --method oidc
See Infra Vault docs for setup.
Alternatively, if you already have a key, you can skip Vault entirely by setting:
export KIBANA_EIS_CCM_API_KEY=<your-key>
Credentials: The script automatically detects Elasticsearch credentials from:
ES_USERNAME/ES_PASSWORD or ELASTICSEARCH_USERNAME/ELASTICSEARCH_PASSWORDelastic:changeme (stateful) or elastic_serverless:changeme (serverless)Custom host/port (optional): By default the script connects to localhost:9200 (trying both HTTPS and HTTP). Override with:
export ES_HOST=my-host # tries both HTTPS and HTTP
export ES_HOST=https://my-host # uses HTTPS only
export ES_PORT=9220
# Terminal 1: Start Elasticsearch with the EIS URL
yarn es snapshot --license trial -E xpack.inference.elastic.url=https://inference.eu-west-1.aws.svc.qa.elastic.cloud
# Terminal 2: Configure EIS API key, once Elasticsearch is green
node scripts/eis.js
The script will:
xpack.inference.elastic.url) is configuredKIBANA_EIS_CCM_API_KEY env var, or from Vault)Important: the script only enables EIS. It does not go through the full Cloud Connect onboarding. The cluster will not show as connected on the Cloud Connect page in Kibana. However, you should have access to all built-in EIS inference endpoints after running this script.