Skip to content

OpenRouter: failed to deserialize api response: error:missing field status #503

@ebamberg

Description

@ebamberg

I am new to Rust and new to async_openai library and trying to use the OpenAIConfig with openrouter.ai, see code below.

I receive an error when async_openai tries to deserialise the response from openrouter cause the field status is missing in the response.

Error: failed to deserialize api response: error:missing field status

is this a bug, or do I do something wrong ? Do I need somekind of a custom response type for OpenRouter ?

my code (as I said I am new to Rust as well.)

let config = OpenAIConfig::new()
.with_api_key(api_key)
.with_api_base("https://openrouter.ai/api/v1");

let client = Client::with_config(config);

let request = CreateResponseArgs::default()
    .model(model)
    .input("What is the capitol of France?")
    .max_output_tokens(512u32)
    .build().unwrap();

let response = client
    .responses()      // Get the API "group" (responses, images, etc.) from the client
    .create(request)  // Make the API call in that "group"
    .await;

match response{
    Ok(response) => println!("Response: {:?}", response.output_text()),
    Err(err) => println!("Error: {}", err),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    out of scopeRequests which are not related to OpenAI API

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions