Skip to content

Wrong response format type when retrieving prompt template from prompt registryΒ #677

@hokaej

Description

@hokaej

Describe the Problem/Bug

I created a Prompt Template with a response format of type ResponseFormatJsonObject (under the prompt.registry library). However, when I get the same prompt template from the prompt registry, the response format under the spec returns as type ResponseFormatText.

I have verified that the prompt template created in the prompt registry does contain the json object response format through the direct api call.

    "response_format": {
      "type": "json_object"
    },

Additionally, tested with the java sdk orchestration's chatCompletion.

Steps to Reproduce

  1. Run the code snippet
  2. Check the spec in the PromptTemplateGetResponse from the call promptClient.getPromptTemplateByUuid(<prompt_id>).
  3. getReq.getSpec().getResponseFormat() returns
class ResponseFormatText {
    type: unknown_default_open_api
}

Expected Behavior

I expected the PromptTemplateGetResponse spec responseFormat to return of type ResponseFormatJsonObject.class.

Screenshots

No response

Used Versions

  • Java and Maven version via mvn --version: 23.0.2

  • SAP Cloud SDK for AI version: tested with 1.9.0 and 1.13.0

  • Spring Boot or CAP version: ...

    Dependency tree via mvn dependency:tree
Dependency tree here

Code Examples

    String scenerio = "categorization";
    // 1. Create Prompt Template
    PromptClient promptClient = new PromptClient();
    var spec = PromptTemplateSpec.create()
            .template(
                    SingleChatTemplate.create().role("system").content("Translate from {{?source_language}} to {{?target_language}}."),
                    SingleChatTemplate.create().role("user").content("{{?sentence}}."))
              .responseFormat(ResponseFormatJsonObject.create().type(ResponseFormatJsonObject.TypeEnum.JSON_OBJECT));

    var postReq = PromptTemplatePostRequest.create()
            .name("translate-template")
            .version("1.0.0")
            .scenario("categorization")
            .spec(spec);
    PromptTemplatePostResponse created = promptClient.createUpdatePromptTemplate(postReq);

    String templateId = created.getId().toString();

    var getReq = promptClient.getPromptTemplateByUuid(created.getId());

Stack Trace

No response

Log File

Log file ...

Affected Development Phase

Development

Impact

Blocked

Timeline

release of our api in mid Jan 2026

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions