Console ↗

JavaScript API reference

Browse the client methods, question builders and TypeScript request and response shapes.

NgilaClientConfiguration, methods and cancellation.noul()Evaluate a yes/no proposition. Supply true and false criteria when each outcome needs a definition.choice()Use an array of candidate names or an object that associates each name with a description.score()Order the levels from lowest to highest. A fractional answer can fall between two levels.box()Ask for one region and identify the source image when more than one image is present.span()Extract zero or more passages from the text values in state. Each match identifies its original source and Unicode code-point offsets.image()Convert a Uint8Array or Node Buffer to a JSON image asset. Specify jpg or png to match the bytes.JsonValueUse nested arrays and objects for structured evidence. Dates need a serialized representation and binary content belongs in assets.ChoiceCriteriaObject keys are returned as labels. Keep keys stable when editing their descriptions.ScoreCriteriaArray order defines the scale. Index zero is the lowest level.NoulCriteriaUse the two descriptions to distinguish a positive case from a near miss.ChoiceQuestionDefine a question for a category from a finite list.ScoreQuestionDefine a question for a position on an ordered scale.NoulQuestionDefine a question for the probability of a yes answer.BoxQuestionDefine a question for a region in an image.SpanQuestionDefine a question for matching text passages in state.SpanMatchResolve path against the original state. Slice the resulting string from start (inclusive) to end (exclusive) using Unicode code points. text contains that slice and confidence applies to this match.SpanResponseRead spans as the primary output. Inspect the additional fields when deciding how to use it.QuestionInspect type to dispatch to the matching question definition.QuestionsEach key identifies an independent judgment. The same keys appear under result.answers.AssetMap a name such as <photo> to these image bytes, then reference that name from state or instructions.BoxCoordinatesMultiply horizontal edges by image width and vertical edges by height. The origin is the upper left.ProbabilitiesEach property gives the weight of one candidate. Keep full precision until formatting for display.ChoiceResponseRead choice as the primary output. Inspect the additional fields when deciding how to use it.ScoreResponseRead score as the primary output. Inspect the additional fields when deciding how to use it.NoulResponseRead noul as the primary output. Inspect the additional fields when deciding how to use it.BoxResponseRead box as the primary output. Inspect the additional fields when deciding how to use it.AnswerUse the type discriminator before reading a field specific to one primitive.SystemOneRequestSend the evidence once and reference its fields from multiple questions.UsageMultiply input_tokens by the current input price. Output tokens currently have no charge.SystemOneResultPreserve the request ID with operational logs. Look up each named answer and record the input token count.ModelCardPass id as the model field when constructing a decision request.ModelsRead data[] to enumerate model identifiers available to the calling key.RequestOptionsUse a request-specific AbortSignal to set a deadline or cancel waiting.NgilaClientConfigKeep apiKey in a trusted server process. timeout is measured in milliseconds.NgilaErrorErrorAPIErrorNgilaErrorAPIConnectionErrorNgilaErrorAPITimeoutErrorAPIConnectionErrorAPIUserAbortErrorAPIConnectionErrorAuthenticationErrorHTTP 401BadRequestErrorHTTP 400InsufficientCreditErrorHTTP 402PermissionDeniedErrorHTTP 403NotFoundErrorHTTP 404RateLimitErrorHTTP 429UnprocessableEntityErrorHTTP 422InternalServerErrorHTTP 5xx